Navigation

Reader

Read-only environment effect: ask/asks/local with standard handler.

ask

ask: read the current environment threaded by the reader handler; impure request whose response IS the handler state.

ask : Computation env

Read the current environment.

asks

asks: read a projection of the environment via a user-supplied function; sugar for bind ask (env: pure (f env)).

asks : (env -> a) -> Computation a

Read a projection of the environment.

handler

reader.handler: interprets ask/local effects with state IS the (immutable) environment; ask resumes with state, local replaces it.

Standard reader handler. Interprets ask effects. The state IS the environment (immutable through the computation).

handle { handlers = reader.handler; state = myEnv; } comp

local

local: run a sub-computation under a modifier-transformed environment; sends local so handlers can install the modified env.

local : (env -> env) -> Computation a -> Computation a

Run a computation with a modified environment. Returns a new computation that transforms the environment before executing the inner computation.

Since handlers are pure functions, local is implemented by wrapping the inner computation's ask effects with the modifier. In practice, use separate handler installation with the modified env.