ether-0.4.2.0: Monad transformers and classes

Safe HaskellNone
LanguageHaskell2010

Control.Monad.Ether.Reader

Contents

Description

Synopsis

MonadReader class

class Monad m => MonadReader tag r m | m tag -> r where Source #

Minimal complete definition

(ask | reader), local

Methods

ask :: proxy tag -> m r Source #

Retrieves the monad environment.

local :: proxy tag -> (r -> r) -> m a -> m a Source #

Executes a computation in a modified environment.

reader :: proxy tag -> (r -> a) -> m a Source #

Retrieves a function of the current environment.

Instances

(LiftLocal t, Monad (t m), MonadReader k tag r m) => MonadReader k tag r (t m) Source # 

Methods

ask :: proxy r -> m (t m) Source #

local :: proxy r -> (t m -> t m) -> m a -> m a Source #

reader :: proxy r -> (t m -> a) -> m a Source #

(Monad m, (~) * r r') => MonadReader k tag r (ReaderT k tag r' m) Source # 

Methods

ask :: proxy r -> m (ReaderT k tag r' m) Source #

local :: proxy r -> (ReaderT k tag r' m -> ReaderT k tag r' m) -> m a -> m a Source #

reader :: proxy r -> (ReaderT k tag r' m -> a) -> m a Source #

asks Source #

Arguments

:: MonadReader tag r m 
=> proxy tag 
-> (r -> a)

The selector function to apply to the environment.

-> m a 

Retrieves a function of the current environment.

The Reader monad

type Reader tag r = ReaderT tag r Identity Source #

The parameterizable reader monad.

Computations are functions of a shared environment.

The return function ignores the environment, while >>= passes the inherited environment to both subcomputations.

runReader :: proxy tag -> Reader tag r a -> r -> a Source #

Runs a ReaderT with the given environment and returns the final value.

The ReaderT monad transformer

type ReaderT tag r = TaggedTrans tag (ReaderT r) Source #

The reader monad transformer, which adds a read-only environment to the given monad.

The return function ignores the environment, while >>= passes the inherited environment to both subcomputations.

readerT :: proxy tag -> (r -> m a) -> ReaderT tag r m a Source #

Constructor for computations in the reader monad transformer.

runReaderT :: proxy tag -> ReaderT tag r m a -> r -> m a Source #

Runs a ReaderT with the given environment and returns the final value.