summaryrefslogtreecommitdiff
path: root/app/Interpreter.hs
diff options
context:
space:
mode:
authorMirek Kratochvil <exa.exa@gmail.com>2023-01-14 23:12:25 +0100
committerMirek Kratochvil <exa.exa@gmail.com>2023-01-14 23:12:25 +0100
commitd9f5bcc0f957fbc148e3d58102d87e95859410e3 (patch)
tree282e837474d285d4d3a9ab13ae3c76d8c3f8d184 /app/Interpreter.hs
parent80cf4b03a4b2353de68a3adc3304334b8a7e347d (diff)
downloadprlg-d9f5bcc0f957fbc148e3d58102d87e95859410e3.tar.gz
prlg-d9f5bcc0f957fbc148e3d58102d87e95859410e3.tar.bz2
simplify uni of consts
Diffstat (limited to 'app/Interpreter.hs')
-rw-r--r--app/Interpreter.hs8
1 files changed, 3 insertions, 5 deletions
diff --git a/app/Interpreter.hs b/app/Interpreter.hs
index 774c13d..439418c 100644
--- a/app/Interpreter.hs
+++ b/app/Interpreter.hs
@@ -162,8 +162,6 @@ proveStep = St.get >>= go
FreeRef gr -> setHeap hr (HeapRef gr)
BoundRef addr _ -> setHeap hr (HeapRef addr)
_ -> ifail "dangling goal ref (from head ref)"
- BoundRef _ atom@(Atom _) -> unify atom g
- BoundRef _ number@(Number _) -> unify number g
BoundRef addr struct@(Struct Id {arity = arity}) ->
c
i
@@ -175,13 +173,12 @@ proveStep = St.get >>= go
, gol = U g : gs
}
}
+ BoundRef _ x -> unify x g
_ -> ifail "dangling head ref"
unify h (HeapRef gr') =
case deref gr' of
FreeRef gr ->
case h of
- atom@(Atom _) -> setHeap gr atom
- number@(Number _) -> setHeap gr number
s@(Struct _) ->
withNewHeapStruct
gr
@@ -194,7 +191,7 @@ proveStep = St.get >>= go
cur
{hed = hs, gol = map U ngs ++ gs, heap = nheap}
})
- BoundRef _ atom@(Atom b) -> unify h atom
+ x -> setHeap gr x
BoundRef addr struct@(Struct Id {arity = arity}) ->
c
i
@@ -206,6 +203,7 @@ proveStep = St.get >>= go
[U (HeapRef $ addr + i) | i <- [1 .. arity]] ++ gs
}
}
+ BoundRef _ x -> unify h x
_ -> ifail "dangling goal ref"
unify _ _ = backtrack
{- Resolution -}