bluefin-0.6.0.0: The Bluefin effect system
Safe HaskellNone
LanguageHaskell2010

Bluefin.Capability.Ask

Synopsis

Documentation

Ask is Bluefin's version of the Control.Monad.Trans.Reader monad. local allows you to locally override the asked value in a well-scoped way. The original value will be restored when you exit the local block regardless of whether the exit was normal or via an exception.

Capability

type Ask = Reader #

Handlers

runAsk #

Arguments

:: forall r (es :: Effects) a. r

Initial value for Ask.

-> (forall (e :: Effects). Ask r e -> Eff (e :& es) a) 
-> Eff es a 

Effectful operations

ask #

Arguments

:: forall (e :: Effects) (es :: Effects) r. e <: es 
=> Reader r e

͘

-> Eff es r 

Read the value. Note that ask has the property that these two operations are always equivalent:

do
  r1 <- ask re
  r2 <- ask re
  pure (r1, r2)
do
  r <- ask re
  pure (r, r)

asks #

Arguments

:: forall (e :: Effects) (es :: Effects) r a. e <: es 
=> Reader r e 
-> (r -> a)

Read the value modified by this function

-> Eff es a 

Read the value modified by a function

local #

Arguments

:: forall (e1 :: Effects) (es :: Effects) r a. e1 <: es 
=> Reader r e1 
-> (r -> r)

In the body, the reader value is modified by this function.

-> Eff es a

Body

-> Eff es a 

Locally override the value in the Reader. It will be restored when the local block ends.