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

Effectful.Labeled.Reader

Description

Convenience functions for the Labeled Reader effect.

Since: 2.4.0.0

Synopsis

Effect

data Reader r :: Effect where Source #

Constructors

Ask :: Reader r m r 
Local :: (r -> r) -> m a -> Reader r m a 

Instances

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

Defined in Effectful.Reader.Dynamic

Handlers

runReader Source #

Arguments

:: forall label r es a. HasCallStack 
=> r

The initial environment.

-> Eff (Labeled label (Reader r) : es) a 
-> Eff es a 

Run the Reader effect with the given initial environment (via Effectful.Reader.Static).

Operations

ask :: forall label r es. (HasCallStack, Labeled label (Reader r) :> es) => Eff es r Source #

Fetch the value of the environment.

asks Source #

Arguments

:: forall label r es a. (HasCallStack, Labeled label (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

:: forall label r es a. (HasCallStack, Labeled label (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