Skip to content

Instantly share code, notes, and snippets.

@khibino
Last active August 7, 2018 16:25
Show Gist options
  • Save khibino/c63056189e5a4d2c5d71 to your computer and use it in GitHub Desktop.
Save khibino/c63056189e5a4d2c5d71 to your computer and use it in GitHub Desktop.
import Prelude hiding (sum)
data L1
= F { ($$) :: L1 -> L1 }
| V { unV :: Int }
infixl 1 $$
instance Show L1 where
show (F _) = "Function"
show (V i) = "V " ++ show i
sum :: L1
sum = F $ \f -> F $ sum' f
where
sum' f (V 0) = V 0
sum' f (V n) = V $ n + (unV (f $$ (V $ n - 1)))
k :: L1
k = F $ \x -> F $ \_ -> x
s :: L1
s = F $ \f -> F $ \g -> F $ \x -> f $$ x $$ (g $$ x)
i :: L1
i = s $$ k $$ k
y :: L1
y = s $$ s $$ k $$ (s $$ (k $$ (s $$ s $$ (s $$ (s $$ s $$ k)))) $$ k)
-- y f = f (y f)
main = undefined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment