module Control.Monad.Freer
(
Eff
, Member
, Members
, send
, Arr
, run
, runM
, runNat
, runNatS
, handleRelay
, handleRelayS
)
where
import Control.Applicative (pure)
import Control.Monad ((>>=))
import Data.Function (($), (.), const)
import Data.Tuple (uncurry)
import Control.Monad.Freer.Internal
( Arr
, Eff
, Member
, Members
, handleRelay
, handleRelayS
, run
, runM
, send
)
runNat
:: Member m effs
=> (forall a. eff a -> m a)
-> Eff (eff ': effs) b
-> Eff effs b
runNat f = handleRelay pure $ \e -> (send (f e) >>=)
runNatS
:: Member m effs
=> s
-> (forall a. s -> eff a -> m (s, a))
-> Eff (eff ': effs) b
-> Eff effs b
runNatS s0 f =
handleRelayS s0 (const pure) $ \s e -> (send (f s e) >>=) . uncurry