Skip to content

Instantly share code, notes, and snippets.

@tlockney
tlockney / quick-haskell-emacs.applescript
Created November 11, 2011 01:39
Set up a frame for trying out simple haskell snippets
(defun make-quick-haskell-frame ()
"Creates a new frame running haskell-mode."
(make-frame '((name . "Quick Haskell")
(width . 120)
(height . 40)))
(select-frame-by-name "Quick Haskell")
(switch-to-buffer "Haskell")
(haskell-mode))
@klapaucius
klapaucius / _post.md
Last active November 7, 2021 22:36
spine-strict_lists

Строгость и нищета списков.

Map и структурная рекурсия.

Применить функцию к каждому элементу списка - это просто:

GHC/Base.lhs

map _ []     = []
map f (x:xs) = f x : map f xs
{-# LANGUAGE StandaloneDeriving, FlexibleContexts, UndecidableInstances #-}
-- Laungh ghci with -fobject-code to make the Fix/Tree trick work (thanks edwardk).
-- courtesy of hpc on #haskell
import Unsafe.Coerce
import Control.Monad.ST
toInteger :: Int -> Integer
isJust :: Maybe a -> Bool
null :: [a] -> Bool
@thoughtpolice
thoughtpolice / typenats.hs
Created April 9, 2012 18:48
Type literals
-- probably broken
-- no polymorphic kind signatures, which may make things cleaner
{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeOperators#-}
@Moligaloo
Moligaloo / DefaultFontFallbacks.plist
Created July 26, 2012 05:57
The plist to replace default font of Mac OS X
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- default ordered fallback list - fallback entity has to be PostScript name -->
<key>default</key>
<array>
<string>LucidaGrande</string> <!-- MAKE sure this matches the kCTFontSystemFontType in CTFontDescriptorCreateForUIType() & TDescriptorSourceImp::CreateDefaultDescriptor()! -->
<string>AppleSymbolsFB</string>
<string>GeezaPro</string>
@brandonb927
brandonb927 / osx-for-hackers.sh
Last active November 14, 2024 17:18
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx
@sjoerdvisscher
sjoerdvisscher / liftedMonoid.hs
Last active April 7, 2020 09:41
If you have a Functor f with an instance Monoid a => Monoid (f a), f is Applicative!
{-# LANGUAGE QuantifiedConstraints, ScopedTypeVariables #-}
import Data.Monoid
-- Note: fails for instances that don't need the Monoid a or Semigroup a
pureDefault :: forall f a. (Functor f, forall a. Monoid a => Monoid (f a)) => a -> f a
pureDefault a = a <$ (mempty :: f ())
apDefault :: (Functor f, forall a. Semigroup a => Semigroup (f a)) => f (a -> b) -> f a -> f b
@tomjaguarpaw
tomjaguarpaw / lensesForArrows.lhs
Last active June 19, 2018 21:14
Lenses for Arrows describes how the Lens datatype from Control.Lens can be generalise to support arrows.
> {-# LANGUAGE Rank2Types #-}
>
> import Prelude hiding (id)
> import Data.Functor.Constant (Constant(Constant), getConstant)
> import Control.Arrow (Arrow, arr, first, Kleisli(Kleisli), runKleisli, (&&&))
> import Control.Category ((<<<))
> import Control.Lens (sequenceAOf)
> import qualified Control.Lens as L
> import qualified Control.Lens.Internal.Setter as LS
> import Data.Profunctor (Profunctor, rmap)
@stbuehler
stbuehler / hackage-upload-docs.sh
Last active October 6, 2017 22:48
Generate and upload docs for hackage packages
#!/bin/bash
# Options / Usage
# put this script in the same directory as your *.cabal file
# it will use the first line of "cabal info ." to determine the package name
# custom options for "cabal haddock" (cabal haddock --help,
# http://www.haskell.org/haddock/doc/html/invoking.html)
CUSTOM_OPTIONS=(--haddock-options='-q aliased')
# hackage server to upload to (and to search uploaded versions for)
@sebastiaanvisser
sebastiaanvisser / gist:9639321
Created March 19, 2014 10:48
Echo: A small FRP library.
-- | Echo: a small experimental library for functional reactive programming.
{-# LANGUAGE
GADTs
, GeneralizedNewtypeDeriving
, TemplateHaskell
, RecursiveDo
, MagicHash
, UnboxedTuples
#-}