summaryrefslogtreecommitdiff
path: root/stdlib.hs
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2017-12-09 10:48:58 +0100
committertomsmeding <tom.smeding@gmail.com>2017-12-09 10:48:58 +0100
commit897fb17dd6a045a7056e6d6babbbb24748f698f6 (patch)
tree65f0659483ba2239d07e30b3547379625f5b5cae /stdlib.hs
Initial
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