extensible-effects-2.0.0.0: An Alternative to Monad Transformers

Safe HaskellSafe
LanguageHaskell2010

Control.Eff.Reader.Lazy

Description

Lazy read-only state

Synopsis

Documentation

newtype Reader e v Source #

The Reader monad

The request for a value of type e from the current environment This can be expressed as a GADT because the type of values returned in response to a (Reader e a) request is not any a; we expect in reply the value of type e, the value from the environment. So, the return type is restricted: 'a ~ e' data Reader e v where Reader :: Reader e e

One can also define this as data Reader e v = (e ~ v) => Reader and even without GADTs, using explicit coercion as is done here.

In the latter case, when we make the request, we make it as Reader id. So, strictly speaking, GADTs are not really necessary.

Constructors

Reader (e -> v) 

ask :: Member (Reader e) r => Eff r e Source #

Get the current value from a Reader. The signature is inferred (when using NoMonomorphismRestriction).

local :: forall e a r. Member (Reader e) r => (e -> e) -> Eff r a -> Eff r a Source #

Locally rebind the value in the dynamic environment This function is like a relay; it is both an admin for Reader requests, and a requestor of them. The underscore is used to disable name-shadowing warning.

reader :: Member (Reader e) r => (e -> a) -> Eff r a Source #

Request the environment value using a transformation function.

runReader :: Eff (Reader e ': r) w -> e -> Eff r w Source #

The handler of Reader requests. The return type shows that all Reader requests are fully handled.