Safe, optimal base monad lifting interface for monads isomorphic to ReaderT.
Both the handle pattern
and the reader pattern
notice that services in Haskell are often IO effects, parameterized by an environment type:
type ServiceH a = Env -> IO a -- handle pattern
type ServiceR a = ReaderT Env IO a -- reader pattern
newtype ServiceM a = ServiceM {runServiceM :: Env -> IO a} -- tagged reader patternFor lifting IO operations, liftIO is handy, but it doesn't work for IO operations
that make use of continuation-passing-style like withFile or bracket.
The MonadBaseReader class provides a simple base monad lifting interface which
does support continuation-passing-style.
Unlike monad-control
but like unliftio
and unlift,
monad-base-reader is restricted to ReaderT-isomorphic monads.
Unlike unliftio but like monad-control and unlift,
monad-base-reader is not restricted to IO base monads.
Unlike either monad-control, unlift or unliftio,
monad-base-reader's environment type is explicit,
not existentially quantified.