Control.Monad.Reader
- Package
- transformers
- Repository
- purescript/purescript-transformers
This module defines the Reader monad.
#withReader Source
withReader :: forall r1 r2 a. (r2 -> r1) -> Reader r1 a -> Reader r2 aChange the type of the context in a Reader monad action.
Re-exports from Control.Monad.Reader.Class
#MonadAsk Source
class MonadAsk :: Type -> (Type -> Type) -> Constraintclass (Monad m) <= MonadAsk r m | m -> r where
The MonadAsk type class represents those monads which support a global
context that can be provided via the ask function.
An implementation is provided for ReaderT, and for other monad
transformers defined in this library.
Law:
do { ask ; ask } = ask
Members
ask :: m r
Instances
#MonadReader Source
class MonadReader :: Type -> (Type -> Type) -> Constraintclass (MonadAsk r m) <= MonadReader r m | m -> r where
An extension of the MonadAsk class that introduces a function local f x
that allows the value of the local context to be modified for the duration
of the execution of action x.
An implementation is provided for ReaderT, and for other monad
transformers defined in this library.
Laws in addition to the MonadAsk law:
local f ask = f <$> asklocal _ (pure a) = pure alocal f (do { a <- x ; y }) = do { a <- local f x ; local f y }
Members
local :: forall a. (r -> r) -> m a -> m a
Instances
MonadReader r (Function r)
Re-exports from Control.Monad.Reader.Trans
#ReaderT Source
newtype ReaderT :: forall k. Type -> (k -> Type) -> k -> Typenewtype ReaderT r m a
The reader monad transformer.
This monad transformer extends the base monad transformer with a global context of
type r.
The MonadReader type class describes the operations supported by this monad.
Constructors
ReaderT (r -> m a)
Instances
Newtype (ReaderT r m a) _(Functor m) => Functor (ReaderT r m)(Apply m) => Apply (ReaderT r m)(Applicative m) => Applicative (ReaderT r m)(Alt m) => Alt (ReaderT r m)(Plus m) => Plus (ReaderT r m)(Alternative m) => Alternative (ReaderT r m)(Bind m) => Bind (ReaderT r m)(Monad m) => Monad (ReaderT r m)(MonadZero m) => MonadZero (ReaderT r m)(Apply m, Semigroup a) => Semigroup (ReaderT s m a)(Applicative m, Monoid a) => Monoid (ReaderT s m a)(MonadPlus m) => MonadPlus (ReaderT r m)MonadTrans (ReaderT r)(MonadEffect m) => MonadEffect (ReaderT r m)(MonadCont m) => MonadCont (ReaderT r m)(MonadThrow e m) => MonadThrow e (ReaderT r m)(MonadError e m) => MonadError e (ReaderT r m)(Monad m) => MonadAsk r (ReaderT r m)(Monad m) => MonadReader r (ReaderT r m)(MonadState s m) => MonadState s (ReaderT r m)(MonadTell w m) => MonadTell w (ReaderT r m)(MonadWriter w m) => MonadWriter w (ReaderT r m)(Distributive g) => Distributive (ReaderT e g)(MonadRec m) => MonadRec (ReaderT r m)
#MonadTrans Source
class MonadTrans :: ((Type -> Type) -> Type -> Type) -> Constraintclass MonadTrans t where
The MonadTrans type class represents monad transformers.
A monad transformer is a type constructor of kind (* -> *) -> * -> *, which
takes a Monad as its first argument, and returns another Monad.
This allows us to add additional effects to an existing monad. By iterating this process, we create monad transformer stacks, which contain all of the effects required for a particular computation.
The laws state that lift is a Monad morphism.
Laws:
lift (pure a) = pure alift (do { x <- m ; y }) = do { x <- lift m ; lift y }
Members
#withReaderT Source
withReaderT :: forall r1 r2 m a. (r2 -> r1) -> ReaderT r1 m a -> ReaderT r2 m aChange the type of the context in a ReaderT monad action.
#runReaderT Source
runReaderT :: forall r m a. ReaderT r m a -> (r -> m a)Run a computation in the ReaderT monad.
#mapReaderT Source
mapReaderT :: forall r m1 m2 a b. (m1 a -> m2 b) -> ReaderT r m1 a -> ReaderT r m2 bChange the type of the result in a ReaderT monad action.
- Modules
- Control.
Comonad. Env - Control.
Comonad. Env. Class - Control.
Comonad. Env. Trans - Control.
Comonad. Store - Control.
Comonad. Store. Class - Control.
Comonad. Store. Trans - Control.
Comonad. Traced - Control.
Comonad. Traced. Class - Control.
Comonad. Traced. Trans - Control.
Comonad. Trans. Class - Control.
Monad. Cont - Control.
Monad. Cont. Class - Control.
Monad. Cont. Trans - Control.
Monad. Error. Class - Control.
Monad. Except - Control.
Monad. Except. Trans - Control.
Monad. Identity. Trans - Control.
Monad. List. Trans - Control.
Monad. Maybe. Trans - Control.
Monad. RWS - Control.
Monad. RWS. Trans - Control.
Monad. Reader - Control.
Monad. Reader. Class - Control.
Monad. Reader. Trans - Control.
Monad. State - Control.
Monad. State. Class - Control.
Monad. State. Trans - Control.
Monad. Trans. Class - Control.
Monad. Writer - Control.
Monad. Writer. Class - Control.
Monad. Writer. Trans