Skip to content

Instantly share code, notes, and snippets.

@fumieval
Created November 19, 2012 23:34
Show Gist options
  • Save fumieval/4114850 to your computer and use it in GitHub Desktop.
Save fumieval/4114850 to your computer and use it in GitHub Desktop.
{-# LANGUAGE TypeFamilies, MultiParamTypeClasses, FlexibleInstances, TypeOperators #-}
infixr 5 :>
data BigCrunch = BigCrunch
data f :> u = f :> u
class Universe a b u where
runUniverse :: u -> a -> b
instance (Universe b c u, a0 ~ a) => Universe a0 c ((a -> b) :> u) where
runUniverse (f :> u) = runUniverse u . f
instance (a0 ~ a) => Universe a0 a BigCrunch where
runUniverse BigCrunch = id
univ
:: (Integer -> Integer)
:> (Integer -> Integer)
:> (Integer -> String)
:> ([a] -> [a])
:> BigCrunch
univ = (*3) :> subtract 3 :> show :> reverse :> BigCrunch
main = print $ runUniverse univ 42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment