summaryrefslogtreecommitdiff
path: root/app/Builtins.hs
diff options
context:
space:
mode:
authorMirek Kratochvil <exa.exa@gmail.com>2022-11-26 16:03:45 +0100
committerMirek Kratochvil <exa.exa@gmail.com>2022-11-26 16:03:45 +0100
commit1cca8b8dce327369a81d97e68129aa3f1da39a33 (patch)
tree21b2245e152aba4132639bce9cee75f90bb9c2d2 /app/Builtins.hs
parent83e1cb5cc71e28adc444d8ea70b9530e06a64f08 (diff)
downloadprlg-1cca8b8dce327369a81d97e68129aa3f1da39a33.tar.gz
prlg-1cca8b8dce327369a81d97e68129aa3f1da39a33.tar.bz2
assert actually recompiles
Diffstat (limited to 'app/Builtins.hs')
-rw-r--r--app/Builtins.hs16
1 files changed, 4 insertions, 12 deletions
diff --git a/app/Builtins.hs b/app/Builtins.hs
index cc0a4e9..b81d298 100644
--- a/app/Builtins.hs
+++ b/app/Builtins.hs
@@ -9,6 +9,7 @@ import Code
, Interp(..)
, heapStruct
)
+import qualified Compiler as Co
import Control.Monad.IO.Class (liftIO)
import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.State.Lazy (get, gets, modify)
@@ -73,19 +74,10 @@ assertFact :: BuiltinFn
assertFact = do
scope <- gets (hvar . cur)
heap <- gets (heap . cur)
- {- TODO this needs to go through PrlgInt because of cuts in assertClause -}
- let atom a = Just [U a]
- struct s args = Just (U s : concat args)
- hrec (HeapRef tgt) src
- | src == tgt = Just [U (LocalRef tgt 0)]
- | otherwise = Nothing
- code = heapStruct atom struct hrec heap . fst $ scope M.! 0
- case code of
+ case Co.compileGoal . Co.struct2goal . Co.squashVars <$>
+ Co.heapStructPrlgInt Nothing heap (fst $ scope M.! 0) of
Just (U (Struct s):head) -> do
- addClause s (head ++ [NoGoal])
- return Nothing
- Just [U (Atom a)] -> do
- addClause (IR.Id a 0) [NoGoal]
+ addClause s $ head ++ [NoGoal]
return Nothing
_ -> backtrack