effectful-core-2.2.2.0: An easy to use, performant extensible effects library.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Effectful.Reader.Static

Description

Support for access to a read only value of a particular type.

Synopsis

Effect

data Reader r :: Effect Source #

Provide access to a strict (WHNF), thread local, read only value of type r.

Instances

Instances details
type DispatchOf (Reader r) Source # 
Instance details

Defined in Effectful.Reader.Static

newtype StaticRep (Reader r) Source # 
Instance details

Defined in Effectful.Reader.Static

newtype StaticRep (Reader r) = Reader r

Handlers

runReader Source #

Arguments

:: r

The initial environment.

-> Eff (Reader r ': es) a 
-> Eff es a 

Run a Reader effect with the given initial environment.

withReader Source #

Arguments

:: (r1 -> r2)

The function to modify the environment.

-> Eff (Reader r2 ': es) a

Computation to run in the modified environment.

-> Eff (Reader r1 ': es) a 

Execute a computation in a modified environment.

Since: 1.1.0.0

Operations

ask :: Reader r :> es => Eff es r Source #

Fetch the value of the environment.

asks Source #

Arguments

:: Reader r :> es 
=> (r -> a)

The function to apply to the environment.

-> Eff es a 

Retrieve a function of the current environment.

asks f ≡ f <$> ask

local Source #

Arguments

:: Reader r :> es 
=> (r -> r)

The function to modify the environment.

-> Eff es a 
-> Eff es a 

Execute a computation in a modified environment.

runReader r (local f m) ≡ runReader (f r) m