:clown: KV-store

This commit is contained in:
2024-10-04 14:45:28 +02:00
parent 46aa789d64
commit 4ddb42582a
32 changed files with 39 additions and 16 deletions

View File

@ -15,6 +15,12 @@ runEval = runEval' envEmpty stateInitial
in (p : ps, res)
runEval' r s (Free (TryCatchOp m l)) =
case (runEval' r s m) of
(_, Left e) -> runEval' r s l
(_, Left _) -> runEval' r s l
a -> a
runEval' r s (Free (KvGetOp key k)) =
case (lookup key s) of
Just val -> runEval' r s $ k val
Nothing -> ([], Left "Cannot find key :)")
runEval' r s (Free (KvPutOp key val m)) =
runEval' r ((key,val):s) m
runEval' _ _ (Free (ErrorOp e)) = ([], Left e)