Coding style and documentation for runNat{,S}

This commit is contained in:
Peter Trško 2017-02-11 08:47:11 +01:00
parent 5eaff723a0
commit a872d81981

View File

@ -42,24 +42,26 @@ module Control.Monad.Freer
import Control.Applicative (pure)
import Control.Monad ((>>=))
import Data.Function ((.), const)
import Data.Function (($), (.), const)
import Data.Tuple (uncurry)
import Control.Monad.Freer.Internal
-- | Variant of 'handleRelay' simplified for the common case.
runNat
:: Member m effs
=> (forall a. eff a -> m a)
-> Eff (eff ': effs) b
-> Eff effs b
runNat f = handleRelay pure (\b -> (send (f b) >>=))
runNat f = handleRelay pure $ \e -> (send (f e) >>=)
-- | Variant of 'handleRelayS' simplified for the common case.
runNatS
:: Member m effs
=> s
-> (forall a. s -> eff a -> m (s, a))
-> Eff (eff ': effs) w
-> Eff effs w
-> Eff (eff ': effs) b
-> Eff effs b
runNatS s0 f =
handleRelayS s0 (const pure) (\s v -> (send (f s v) >>=) . uncurry)
handleRelayS s0 (const pure) $ \s e -> (send (f s e) >>=) . uncurry