unliftIO

The MonadUnliftIO typeclass for unlifting monads to IO (batteries included) Please see the documentation and README at https://www.stackage.org/package/unliftio
Please see the README.md file for information on using this package at https://www.stackage.org/package/unliftio.
The ability to run any monadic action m a as IO a. This is more precisely a natural transformation. We need to new datatype (instead of simply using a forall) due to lack of support in GHC for impredicative types.
This module presents the same interface as Control.Exception.Annotated, but uses MonadUnliftIO instead of MonadCatch or MonadThrow.
The MonadUnliftIO typeclass for unlifting monads to IO Please see the documentation and README at https://www.stackage.org/package/unliftio-core
Data.Pool generalized to MonadUnliftIO. This is a generalization of Data.Pool to MonadUnliftIO.
UnliftIO using well-typed Paths. UnliftIO using well-typed Paths.
Not on Stackage, so not searched. Fast and robust message queues for concurrent processes
Generalization of io-streams to MonadUnliftIO Generalization of io-streams to MonadUnliftIO.
Not on Stackage, so not searched. Use MonadUnliftIO on servant APIs
Monads which allow their actions to be run in IO. While MonadIO allows an IO action to be lifted into another monad, this class captures the opposite concept: allowing you to capture the monadic context. Note that, in order to meet the laws given below, the intuition is that a monad must have no monadic state, but may have monadic context. This essentially limits MonadUnliftIO to ReaderT and IdentityT transformers on top of IO. Laws. For any function run provided by withRunInIO, it must meet the monad transformer laws as reformulated for MonadUnliftIO:
  • run . return = return
  • run (m >>= f) = run m >>= run . f
Instances of MonadUnliftIO must also satisfy the following laws:
  • Identity law withRunInIO (\run -> run m) = m
  • Inverse law withRunInIO (\_ -> m) = liftIO m
As an example of an invalid instance, a naive implementation of MonadUnliftIO (StateT s m) might be
withRunInIO inner =
StateT $ \s ->
withRunInIO $ \run ->
inner (run . flip evalStateT s)
This breaks the identity law because the inner run m would throw away any state changes in m.
Monads which allow their actions to be run in IO. While MonadIO allows an IO action to be lifted into another monad, this class captures the opposite concept: allowing you to capture the monadic context. Note that, in order to meet the laws given below, the intuition is that a monad must have no monadic state, but may have monadic context. This essentially limits MonadUnliftIO to ReaderT and IdentityT transformers on top of IO. Laws. For any value u returned by askUnliftIO, it must meet the monad transformer laws as reformulated for MonadUnliftIO:
  • unliftIO u . return = return
  • unliftIO u (m >>= f) = unliftIO u m >>= unliftIO
    u . f
Instances of MonadUnliftIO must also satisfy the idempotency law:
  • askUnliftIO >>= \u -> (liftIO . unliftIO u) m =
    m
This law showcases two properties. First, askUnliftIO doesn't change the monadic context, and second, liftIO . unliftIO u is equivalent to id IF called in the same monadic context as askUnliftIO.
Monads which allow their actions to be run in IO. While MonadIO allows an IO action to be lifted into another monad, this class captures the opposite concept: allowing you to capture the monadic context. Note that, in order to meet the laws given below, the intuition is that a monad must have no monadic state, but may have monadic context. This essentially limits MonadUnliftIO to ReaderT and IdentityT transformers on top of IO. Laws. For any function run provided by withRunInIO, it must meet the monad transformer laws as reformulated for MonadUnliftIO:
  • run . return = return
  • run (m >>= f) = run m >>= run . f
Instances of MonadUnliftIO must also satisfy the following laws:
  • Identity law withRunInIO (\run -> run m) = m
  • Inverse law withRunInIO (\_ -> m) = liftIO m
As an example of an invalid instance, a naive implementation of MonadUnliftIO (StateT s m) might be
withRunInIO inner =
StateT $ \s ->
withRunInIO $ \run ->
inner (run . flip evalStateT s)
This breaks the identity law because the inner run m would throw away any state changes in m.
Capture the current monadic context, providing the ability to run monadic actions in IO. See UnliftIO for an explanation of why we need a helper datatype here. Prior to version 0.2.0.0 of this library, this was a method in the MonadUnliftIO type class. It was moved out due to https://github.com/fpco/unliftio/issues/55.
Convenience function for capturing the monadic context and running an IO action. The UnliftIO newtype wrapper is rarely needed, so prefer withRunInIO to this function.
Create a local unlifting function with the given strategy along with an unrestricted lifting function. Useful for lifting complicated IO computations where the monadic action shows in both positive (as a result) and negative (as an argument) position. Note: depending on the computation you're lifting localUnliftIO along with withLiftMapIO might be enough and is more efficient.
Create a local unlifting function with the SeqUnlift strategy. For the general version see localUnliftIO.
Create a local unlifting function with the given strategy.
Create an unlifting function with the ConcUnlift strategy.
Create an unlifting function with the SeqUnlift strategy.
Create an unlifting function with the ConcUnlift strategy. This function is unsafe because it can be used to introduce arbitrary IO actions into pure Eff computations.
Create an unlifting function with the SeqUnlift strategy. This function is unsafe because it can be used to introduce arbitrary IO actions into pure Eff computations.