summaryrefslogtreecommitdiff
path: root/app/Builtins.hs
diff options
context:
space:
mode:
Diffstat (limited to 'app/Builtins.hs')
-rw-r--r--app/Builtins.hs14
1 files changed, 13 insertions, 1 deletions
diff --git a/app/Builtins.hs b/app/Builtins.hs
index 60653df..4164a6c 100644
--- a/app/Builtins.hs
+++ b/app/Builtins.hs
@@ -167,8 +167,10 @@ struct = do
heap <- use (cur . heap)
scope <- use (cur . hvar)
case derefHeap heap <$> scope M.!? 0 of
- Just (BoundRef addr (Struct Id {arity = arity, str = str})) ->
+ Just (BoundRef _ (Struct Id {arity = arity, str = str})) ->
structUnify arity str
+ Just (BoundRef _ _) ->
+ backtrack
_ -> structAssemble
heapListLength listAtom heap ref = go 0 ref ref (id, fromJust . step)
@@ -217,6 +219,7 @@ structUnify arity str = do
zoom cur $ do
gol %= (gcode ++)
hed %= (hcode ++)
+ unis += 3
continue
{- terms -}
@@ -229,6 +232,14 @@ var = do
Just (FreeRef _) -> continue
_ -> backtrack
+atom :: InterpFn
+atom = do
+ heap <- use (cur . heap)
+ scope <- use (cur . hvar)
+ case derefHeap heap <$> scope M.!? 0 of
+ Just (BoundRef _ (C (Atom _))) -> continue
+ _ -> backtrack
+
number :: InterpFn
number = do
heap <- use (cur . heap)
@@ -468,6 +479,7 @@ addPrelude = do
{- terms -}
addBi struct "struct" 3
addBi var "var" 1
+ addBi atom "atom" 1
addBi number "number" 1
addBi string "string" 1
addBi sameTerm "same_term" 2