A function that runs a M
computation on the monadic state that was
captured by liftBaseWith
.
A function that runs a M
computation on the monadic state that was
captured by liftBaseWith
.
A RunInBase
function yields a computation in the base monad of M
that
returns the monadic state of M
. This state can later be used to restore
the M
computation using restoreM
.
Monadic state of m.
liftBaseWith
is similar to liftIO
in that it lifts a base computation
to the constructed monad.
liftBaseWith
is similar to liftIO
in that it lifts a base computation
to the constructed monad.
Instances should satisfy similar laws as the MonadIO
laws:
liftBaseWith . const . return = return liftBaseWith (const (m >>= f)) = liftBaseWith (const m) >>= liftBaseWith . const . f
The difference 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.
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
An often used composition: control f = liftBaseWith f >>= restoreM