0 | module Control.Monad.Elin
2 | import public Control.Monad.MCancel
3 | import public Data.Linear.ELift1
11 | record Elin (s : Type) (es : List Type) (a : Type) where
15 | bindImpl : Elin s es a -> (a -> Elin s es b) -> Elin s es b
17 | E $
\t => case g t of
19 | R v t => run (f v) t
26 | attempt x = E $
\t => pattempt (run x t)
27 | mapImpl f act = E $
\t => mapERes f (act.run t)
28 | appImpl ff fv = bindImpl ff (`mapImpl` fv)
35 | MCancel (Elin s) where
37 | uncancelable body = body id
41 | ELift1 s (Elin s) where
45 | HasIO (Elin World es) where
46 | liftIO = lift1 . ioToF1
53 | runElin : (forall s . Elin s es a) -> Result es a
54 | runElin p = run1 $
\t => toResult (p.run t)
59 | runElinIO : Elin World es a -> IO (Result es a)
60 | runElinIO p = runIO $
\t => toResult (p.run t)