| 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
- liftBase :: b α -> m α
- class MonadTrans t => MonadTransControl t where
- class MonadBase b m => MonadBaseControl b m | m -> b where
- type StM m a :: *
- liftBaseWith :: (RunInBase m b -> b a) -> m a
- restoreM :: StM m a -> m a
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:
Methods
lift :: Monad m => m a -> t m a
Lift a computation from the argument monad to the constructed monad.
Instances
| MonadTrans IdentityT | |
| MonadTrans Free | This is not a true monad transformer. It is only a monad transformer "up to |
| MonadTrans ListT | |
| MonadTrans ResourceT | |
| MonadTrans MaybeT | |
| MonadTrans (ContT r) | |
| MonadTrans (ReaderT r) | |
| MonadTrans (StateT s) | |
| MonadTrans (StateT s) | |
| MonadTrans (ExceptT e) | |
| Error e => MonadTrans (ErrorT e) | |
| Monoid w => MonadTrans (WriterT w) | |
| Monoid w => MonadTrans (WriterT w) | |
| MonadTrans (StateRefT ref s) | |
| MonadTrans (WriterRefT ref w) | |
| Monoid w => MonadTrans (RWST r w s) | |
| Monoid w => MonadTrans (RWST r w s) | |
| MonadTrans (RWSRefT refw refs r w s) |
class (Applicative b, Applicative m, Monad b, Monad m) => MonadBase b m | m -> b where
Instances
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 IdentityT | |
| MonadTransControl ListT | |
| MonadTransControl ResourceT | |
| MonadTransControl MaybeT | |
| MonadTransControl (ReaderT r) | |
| MonadTransControl (StateT s) | |
| MonadTransControl (StateT s) | |
| MonadTransControl (ExceptT e) | |
| Error e => MonadTransControl (ErrorT e) | |
| Monoid w => MonadTransControl (WriterT w) | |
| Monoid w => MonadTransControl (WriterT w) | |
| MonadTransControl (StateRefT ref s) | |
| MonadTransControl (WriterRefT ref w) | |
| Monoid w => MonadTransControl (RWST r w s) | |
| Monoid w => MonadTransControl (RWST r w s) | |
| MonadTransControl (RWSRefT refw refs r w s) |
class MonadBase b m => MonadBaseControl b m | m -> b where
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