aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMarvin Borner2022-07-15 11:54:54 +0200
committerMarvin Borner2022-07-15 11:54:54 +0200
commit88b0f7ed4e9580956f3be1eb50ce7cb10668207e (patch)
treeb770b160e7ddc25175f616b30857c84470e31793
parent495127cde69e0008b8a1c428d5ddf0d805eb25bb (diff)
hmmm
-rw-r--r--src/Eval.hs5
-rw-r--r--std.bruijn10
2 files changed, 9 insertions, 6 deletions
diff --git a/src/Eval.hs b/src/Eval.hs
index 5744e21..ebca545 100644
--- a/src/Eval.hs
+++ b/src/Eval.hs
@@ -90,7 +90,10 @@ eval (line : ls) state@(EnvState env) isRepl =
then (putStrLn $ name <> " = " <> show exp)
>> return (EnvState env')
else eval ls (EnvState env') isRepl
- Import path -> loadFile path
+ Import path -> do
+ lib <- getDataFileName path -- TODO: Use actual lib directory
+ exists <- doesFileExist lib
+ loadFile $ if exists then lib else path
Evaluate exp ->
let (res, env') = evalExp exp `runState` env
in putStrLn
diff --git a/std.bruijn b/std.bruijn
index b4d4be8..f211a98 100644
--- a/std.bruijn
+++ b/std.bruijn
@@ -45,17 +45,17 @@ upZero [[[[1 (3 2 1 0)]]]]
upOne [[[[0 (3 2 1 0)]]]]
up [[[[[4 1 0 (3 2 1 0)]]]]]
-zero? [0 T I [F]]
+lsb [0 [[[0]]] [[[[0]]]] [[[[1]]]] [[[[0]]]]]
-binZero [[[2]]]
-binOne [[[0 2]]]
+# TODO: almost!
+zero? [0 [[[1]]] [[[[0]]]] [[[[0]]]] [[[[0]]]]]
-_succZ (pair binZero binOne)
+_succZ pair +0 +1
_succA [0 [[pair (upZero 1) (upOne 1)]]]
_succB [0 [[pair (upOne 1) (upZero 0)]]]
succ [snd (0 _succZ _succA _succB)]
-_predZ (pair binZero binZero)
+_predZ pair +0 +1
_predA [0 [[pair (upZero 1) (upOne 0)]]]
_predB [0 [[pair (upOne 1) (upZero 1)]]]
pred [snd (0 _predZ _predA _predB)]