summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2014-03-15 14:31:40 +1100
committerJed Barber <jjbarber@y7mail.com>2014-03-15 14:31:40 +1100
commite9134c3a46de1fc086fa87488c141b16cd828c02 (patch)
treed9d7143d2eb3daf0654149c5e1f1a48c97499312
parent005d847234a84b58b1f2ef1baec8b3fdd238c2df (diff)
Basic unlambda builtins implemented directly in haskell
-rw-r--r--Unlambda/Builtins.hs41
1 files changed, 41 insertions, 0 deletions
diff --git a/Unlambda/Builtins.hs b/Unlambda/Builtins.hs
new file mode 100644
index 0000000..118ca6f
--- /dev/null
+++ b/Unlambda/Builtins.hs
@@ -0,0 +1,41 @@
+module Unlambda.Builtins (
+ k,
+ s,
+ i,
+ dot,
+ r,
+ d
+ ) where
+
+
+
+
+k :: a -> b -> a
+k x y = x
+
+
+
+s :: (a -> b -> c) -> (a -> b) -> a -> c
+s x y z = (x z) (y z)
+
+
+
+i :: a -> a
+i = id
+
+
+
+dot :: Char -> a -> IO a
+dot ch f = putChar ch >> return f
+
+
+
+r :: a -> IO a
+r f = putChar '\n' >> return f
+
+
+
+-- may not work as per unlambda lazy semantics
+d :: (a -> b) -> (a -> b)
+d x = (\y -> x y)
+