MonadTransPeel is the class of monad transformers supporting an
extra operation peel, enabling control operations (functions that
use monadic actions as input instead of just output) to be lifted
through the transformer.
Methods
peel :: (Monad m, Monad n, Monad o) => t n (t m a -> m (t o a))peelis used to peel off the outer layer of a transformed monadic action, allowing an transformed actiont m ato be treated as a base actionm b.More precisely,
peelcaptures the monadic state oftat the point where it is bound (int n), yielding a functiont m a -> m (t o a); this function runs a transformed monadic actiont m ain the base monadmusing the captured state, and leaves the resultt o ain the monadmafter all side effects inmhave occurred.This can be used together with lift to lift control operations with types such as
M a -> M ainto the transformed monadt M:instance Monad M foo :: M a -> M a foo' :: (MonadTransPeel t, Monad (t M)) => t M a -> t M a foo' a = do k <- peel -- k :: t M a -> M (t M a) join $ lift $ foo (k a) -- uses foo :: M (t M a) -> M (t M a)peelis typically used withm == n == o, but is required to be polymorphic for greater type safety: for example, this type ensures that the result of running the action inmhas no remaining side effects inm.
Instances10MonadTransPeel, …
MonadTransPeel MaybeTDefined in monad-peel-0.3 · Control.Monad.Trans.PeelMonoid w => MonadTransPeel (WriterT w)Defined in monad-peel-0.3 · Control.Monad.Trans.PeelMonoid w => MonadTransPeel (WriterT w)Defined in monad-peel-0.3 · Control.Monad.Trans.PeelMonadTransPeel IdentityTDefined in monad-peel-0.3 · Control.Monad.Trans.PeelMonadTransPeel (ExceptT e)Defined in monad-peel-0.3 · Control.Monad.Trans.PeelMonadTransPeel (ReaderT r)Defined in monad-peel-0.3 · Control.Monad.Trans.PeelMonadTransPeel (StateT s)Defined in monad-peel-0.3 · Control.Monad.Trans.PeelMonadTransPeel (StateT s)Defined in monad-peel-0.3 · Control.Monad.Trans.PeelMonoid w => MonadTransPeel (RWST r w s)Defined in monad-peel-0.3 · Control.Monad.Trans.PeelMonoid w => MonadTransPeel (RWST r w s)Defined in monad-peel-0.3 · Control.Monad.Trans.Peel