0 | module Control.Monad.Pure
2 | import public Data.Linear.Token
15 | record Pure (s,a : Type) where
20 | bind : Pure s a -> (a -> Pure s b) -> Pure s b
21 | bind (P v) f = P $
\t => let x # t := v t in run (f x) t
24 | Functor (Pure s) where
25 | map f (P g) = P $
mapF1 f g
28 | Applicative (Pure s) where
30 | ff <*> fv = bind ff (<$> fv)
33 | Monad (Pure s) where
37 | Lift1 s (Pure s) where
41 | HasIO (Pure World) where
42 | liftIO = lift1 . ioToF1
46 | runPure : (forall s . Pure s a) -> a
47 | runPure p = run1 p.run
51 | runPureIO : HasIO io => Pure World a -> io a
52 | runPureIO = runIO . run