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:
The third is a currently nameless law which ensures that the current
context is preserved.
If you have a name for this, please submit it in a pull request for
great glory.