Skip to content

Repository files navigation

monad-base-reader

Safe, optimal base monad lifting interface for monads isomorphic to ReaderT.

motivation

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 pattern

For 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.

comparison

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.

About

Safe, optimal base monad lifting interface for monads isomorphic to `ReaderT`.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages