HORIZON HASKELLDocslts/ghc-9.14.x3e2d5682026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · 3e2d568 · 2026-10-11

Moduleextensible-effects-5.0.0.1Haskell2010

Control.Eff.Reader.Strict

Strict read-only state

  • 1 type
  • 5 values
datadata Reader (e :: k) (v :: k) where
#

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'

One can also define this as

data Reader e v = (e ~ v) => Reader

^ without GADTs, using explicit coercion as is done here.

newtype Reader e v = Reader (e->v)

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

Constructors

Instances3MonadBaseControl, Handle, StM
  • (MonadBase m m, LiftedBase m s) => MonadBaseControl m (Eff (Reader e ': s))Defined in extensible-effects-5.0.0.1 · Control.Eff.Reader.Strict
  • Handle (Reader e) r a (e -> k)Defined in extensible-effects-5.0.0.1 · Control.Eff.Reader.Strict

    Given a value to read, and a callback, how to respond to requests.

  • type StM (Eff (Reader e ': s)) a = StM (Eff s) aDefined in extensible-effects-5.0.0.1 · Control.Eff.Reader.Strict
valuewithReader :: Monad m => a -> e -> m a
#

How to interpret a pure value in a reader context

valueask :: Member (Reader e) r => Eff r e
#

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

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

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.

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

Request the environment value using a transformation function.

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

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