summaryrefslogtreecommitdiff
path: root/stdlib.hs
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib.hs')
-rw-r--r--stdlib.hs16
1 files changed, 16 insertions, 0 deletions
diff --git a/stdlib.hs b/stdlib.hs
new file mode 100644
index 0000000..6f7334f
--- /dev/null
+++ b/stdlib.hs
@@ -0,0 +1,16 @@
+module Stdlib(stdlib) where
+
+import AST
+import Parser
+
+
+stdlib :: Program
+stdlib = fromRight $ parseProgram
+ "(define not (x) (= x 0))\n\
+ \(define id (x) x)\n\
+ \(define nil (x) (= x '()))\n\
+ \(define . (f g) (lambda (x) (f (g x))))\n"
+
+fromRight :: Show a => Either a b -> b
+fromRight (Right b) = b
+fromRight (Left a) = error $ "fromRight on Left: " ++ show a