🎣 Add TryCatchOp and add our eval. catch implementation and runeval missing

This commit is contained in:
2024-10-03 16:32:44 +02:00
parent fcd0ed780e
commit 98d41e6a6d
2 changed files with 23 additions and 1 deletions

View File

@ -76,6 +76,7 @@ data EvalOp a
| StatePutOp State a
| PrintOp String a
| ErrorOp Error
| TryCatchOp a a
instance Functor EvalOp where
fmap f (ReadOp k) = ReadOp $ f . k
@ -83,6 +84,7 @@ instance Functor EvalOp where
fmap f (StatePutOp s m) = StatePutOp s $ f m
fmap f (PrintOp p m) = PrintOp p $ f m
fmap _ (ErrorOp e) = ErrorOp e
fmap f (TryCatchOp m1 m2) = TryCatchOp (f m1) (f m2)
type EvalM a = Free EvalOp a