This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE TypeFamilies #-} | |
type family StateFor a | |
type instance StateFor Integer = () | |
type instance StateFor (a, b) = (StateFor a, StateFor b) | |
type instance StateFor [a] = (Integer, [StateFor a]) | |
class ReadObj a where | |
readObj :: StateFor a -> [[String]] -> (a, [[String]]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let b:align_language_pragma = 0 | |
setlocal cpoptions+=M | |
iabbrev <buffer> H# {-# #-}<Left><Left><Left><Left> | |
iabbrev <buffer> HA Applicative | |
iabbrev <buffer> HB Bounded, Enum, Eq, Ord, Read, Show | |
iabbrev <buffer> HBS ByteString | |
iabbrev <buffer> HC Control | |
iabbrev <buffer> HD Data | |
iabbrev <buffer> Hd deriving ()<Left> | |
iabbrev <buffer> Hda data =<CR>deriving (Eq, Ord, Read, Show)<Up><End><Left><Left> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE AllowAmbiguousTypes #-} | |
{-# LANGUAGE TypeApplications #-} | |
data K = A | B | C | |
data Foo a where | |
FooAny :: Foo a | |
FooAB :: Foo (Fam a) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Y xs where | |
type ToS xs :: TreeS | |
y :: HTree_ (ToS xs) -> HTreeS xs (ToS xs) | |
instance Y TLeaf where | |
type ToS TLeaf = TLeafS | |
y HLeaf_ = x |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foldb1 op = foldb' where | |
pairwise (x:y:rest) = op x y : pairwise rest | |
pairwise shortList = shortList | |
foldb' xs@(_:_:_) = foldb' (pairwise xs) | |
foldb' [x] = x | |
foldb op def xs = foldb1 op (def:xs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fs :: Bool -> Int -> Int | |
fs False = (+1) | |
fs True = (*3) | |
vals :: Bool -> Int | |
vals False = 10 | |
vals True = 20 | |
fOfVals :: Bool -> Int | |
fOfVals = fs <*> vals |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data Zero = Zero deriving Show | |
data Succ n = Succ deriving Show | |
class Foo a where foo :: a | |
instance Foo Zero where foo = Zero | |
instance Foo n => Foo (Succ n) where foo = Succ | |
type Two zero = Succ (Succ zero) | |
type Four zero = Two (Two zero) | |
type Eight zero = Four (Four zero) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.List | |
import System.Environment | |
data SizedTree a = Node Integer a [SizedTree a] deriving (Eq, Ord, Read, Show) | |
type Stream a = [SizedTree a] | |
indexT :: Integer -> SizedTree a -> a | |
indexT 0 (Node _ v _) = v | |
indexT n (Node _ _ vs) = indexS (n-1) vs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.List | |
import System.Environment | |
data SizedTree a = Node Integer a [SizedTree a] deriving (Eq, Ord, Read, Show) | |
type Stream a = [SizedTree a] | |
indexT :: Integer -> SizedTree a -> a | |
indexT 0 (Node _ v _) = v | |
indexT n (Node _ _ vs) = indexS (n-1) vs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <unistd.h> | |
int main() { | |
char *args[3] = {"notsleep", "10", NULL}; | |
return execv("/usr/bin/sleep", args); | |
} |
OlderNewer