| Safe Haskell | Safe |
|---|---|
| Language | Haskell2010 |
Control.Monad.Trans.Unlift
Description
See overview in the README.md
- class (MonadTransControl t, Forall (Identical t)) => MonadTransUnlift t
- newtype Unlift t = Unlift {}
- askUnlift :: forall t m. (MonadTransUnlift t, Monad m) => t m (Unlift t)
- askRun :: (MonadTransUnlift t, Monad (t m), Monad m) => t m (t m a -> m a)
- class (MonadBaseControl b m, Forall (IdenticalBase m)) => MonadBaseUnlift b m | m -> b
- newtype UnliftBase b m = UnliftBase {
- unliftBase :: forall a. m a -> b a
- askUnliftBase :: forall b m. MonadBaseUnlift b m => m (UnliftBase b m)
- askRunBase :: MonadBaseUnlift b m => m (m a -> b a)
- class MonadTrans t where
- class (Applicative b, Applicative m, Monad b, Monad m) => MonadBase b m | m -> b where
- class MonadTrans t => MonadTransControl t where
- class MonadBase b m => MonadBaseControl b m | m -> b where
Trans
class (MonadTransControl t, Forall (Identical t)) => MonadTransUnlift t Source #
A monad transformer which can be unlifted, obeying the monad morphism laws.
Since 0.1.0
Instances
| (MonadTransControl t, Forall * (Identical t)) => MonadTransUnlift t Source # | |
A function which can move an action down the monad transformer stack, by providing any necessary environment to the action.
Note that, if ImpredicativeTypes worked reliably, this type wouldn't be
necessary, and askUnlift would simply include a more generalized type.
Since 0.1.0
askUnlift :: forall t m. (MonadTransUnlift t, Monad m) => t m (Unlift t) Source #
Get the Unlift action for the current transformer layer.
Since 0.1.0
askRun :: (MonadTransUnlift t, Monad (t m), Monad m) => t m (t m a -> m a) Source #
A simplified version of askUnlift which addresses the common case where
polymorphism isn't necessary.
Since 0.1.0
Base
class (MonadBaseControl b m, Forall (IdenticalBase m)) => MonadBaseUnlift b m | m -> b Source #
A monad transformer stack which can be unlifted, obeying the monad morphism laws.
Since 0.1.0
Instances
| (MonadBaseControl b m, Forall * (IdenticalBase m)) => MonadBaseUnlift b m Source # | |
newtype UnliftBase b m Source #
Similar to Unlift, but instead of moving one layer down the stack, moves
the action to the base monad.
Since 0.1.0
Constructors
| UnliftBase | |
Fields
| |
askUnliftBase :: forall b m. MonadBaseUnlift b m => m (UnliftBase b m) Source #
Get the UnliftBase action for the current transformer stack.
Since 0.1.0
askRunBase :: MonadBaseUnlift b m => m (m a -> b a) Source #
A simplified version of askUnliftBase which addresses the common case
where polymorphism isn't necessary.
Since 0.1.0
Reexports
class MonadTrans t where #
The class of monad transformers. Instances should satisfy the
following laws, which state that lift is a monad transformation:
Minimal complete definition
Methods
lift :: Monad m => m a -> t m a #
Lift a computation from the argument monad to the constructed monad.
Instances
| MonadTrans ListT | |
| MonadTrans MaybeT | |
| MonadTrans (ErrorT e) | |
| MonadTrans (ExceptT e) | |
| MonadTrans (StateT s) | |
| MonadTrans (StateT s) | |
| Monoid w => MonadTrans (WriterT w) | |
| Monoid w => MonadTrans (WriterT w) | |
| MonadTrans (IdentityT *) | |
| MonadTrans (ContT * r) | |
| MonadTrans (ReaderT * r) | |
| Monoid w => MonadTrans (RWST r w s) | |
| Monoid w => MonadTrans (RWST r w s) | |
class (Applicative b, Applicative m, Monad b, Monad m) => MonadBase b m | m -> b where #
Minimal complete definition
Instances
| MonadBase [] [] | |
| MonadBase Maybe Maybe | |
| MonadBase IO IO | |
| MonadBase Identity Identity | |
| MonadBase STM STM | |
| MonadBase b m => MonadBase b (MaybeT m) | |
| MonadBase b m => MonadBase b (ListT m) | |
| (Monoid w, MonadBase b m) => MonadBase b (WriterT w m) | |
| (Monoid w, MonadBase b m) => MonadBase b (WriterT w m) | |
| MonadBase b m => MonadBase b (StateT s m) | |
| MonadBase b m => MonadBase b (StateT s m) | |
| MonadBase b m => MonadBase b (IdentityT * m) | |
| MonadBase b m => MonadBase b (ExceptT e m) | |
| (Error e, MonadBase b m) => MonadBase b (ErrorT e m) | |
| MonadBase b m => MonadBase b (ReaderT * r m) | |
| MonadBase b m => MonadBase b (ContT * r m) | |
| (Monoid w, MonadBase b m) => MonadBase b (RWST r w s m) | |
| (Monoid w, MonadBase b m) => MonadBase b (RWST r w s m) | |
| MonadBase ((->) r) ((->) r) | |
| MonadBase (Either e) (Either e) | |
| MonadBase (ST s) (ST s) | |
| MonadBase (ST s) (ST s) | |
class MonadTrans t => MonadTransControl t where #
Methods
liftWith :: Monad m => (Run t -> m a) -> t m a #
liftWith is similar to lift in that it lifts a computation from
the argument monad to the constructed monad.
Instances should satisfy similar laws as the MonadTrans laws:
liftWith . const . return = return
liftWith (const (m >>= f)) = liftWith (const m) >>= liftWith . const . f
The difference with lift is that before lifting the m computation
liftWith captures the state of t. It then provides the m
computation with a Run function that allows running t n computations in
n (for all n) on the captured state.
restoreT :: Monad m => m (StT t a) -> t m a #
Construct a t computation from the monadic state of t that is
returned from a Run function.
Instances should satisfy:
liftWith (\run -> run t) >>= restoreT . return = t
Instances
| MonadTransControl ListT | |
| MonadTransControl MaybeT | |
| Error e => MonadTransControl (ErrorT e) | |
| MonadTransControl (ExceptT e) | |
| MonadTransControl (StateT s) | |
| MonadTransControl (StateT s) | |
| Monoid w => MonadTransControl (WriterT w) | |
| Monoid w => MonadTransControl (WriterT w) | |
| MonadTransControl (IdentityT *) | |
| MonadTransControl (ReaderT * r) | |
| Monoid w => MonadTransControl (RWST r w s) | |
| Monoid w => MonadTransControl (RWST r w s) | |
class MonadBase b m => MonadBaseControl b m | m -> b where #
Minimal complete definition
Methods
liftBaseWith :: (RunInBase m b -> b a) -> m a #
liftBaseWith is similar to liftIO and liftBase in that it
lifts a base computation to the constructed monad.
Instances should satisfy similar laws as the MonadIO and MonadBase laws:
liftBaseWith . const . return = return
liftBaseWith (const (m >>= f)) = liftBaseWith (const m) >>= liftBaseWith . const . f
The difference with liftBase is that before lifting the base computation
liftBaseWith captures the state of m. It then provides the base
computation with a RunInBase function that allows running m
computations in the base monad on the captured state.
Construct a m computation from the monadic state of m that is
returned from a RunInBase function.
Instances should satisfy:
liftBaseWith (\runInBase -> runInBase m) >>= restoreM = m
Instances