cleff-0.3.2.0: Fast and concise extensible effects
Copyright(c) 2021 Xy Ren
LicenseBSD3
Maintainerxy.r@outlook.com
Stabilityexperimental
Portabilitynon-portable (GHC only)
Safe HaskellTrustworthy
LanguageHaskell2010

Cleff.Reader

Description

 
Synopsis

Effect

data Reader r :: Effect where Source #

An effect capable of providing an immutable environment r that can be read. This roughly corresponds to the MonadReader typeclass and ReaderT monad transformer in the mtl library.

Constructors

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

Operations

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

Obtain the environment value.

local Source #

Arguments

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

The function that modifies the environment

-> Eff es a

The computation to run with the modified environment

-> Eff es a 

Modify the environment value temporarily for a computation.

asks :: Reader r :> es => (r -> s) -> Eff es s Source #

Apply a function to the result of ask.

Interpretations

runReader :: r -> Eff (Reader r ': es) ~> Eff es Source #

Run a Reader effect with a given environment value.

magnify :: Reader t :> es => Lens' t r -> Eff (Reader r ': es) ~> Eff es Source #

Run a Reader effect in terms of a larger Reader via a Lens'.