Module

Control.Comonad.Env.Class

Package
transformers
Repository
purescript/purescript-transformers

This module defines the ComonadEnv type class and its instances.

#ComonadAsk Source

class ComonadAsk :: Type -> (Type -> Type) -> Constraintclass (Comonad w) <= ComonadAsk e w | w -> e where

The ComonadEnv type class represents those comonads which support a global environment that can be provided via the ask function.

An implementation is provided for EnvT.

Members

  • ask :: forall a. w a -> e

Instances

#asks Source

asks :: forall e1 e2 w a. ComonadAsk e1 w => (e1 -> e2) -> w a -> e2

Get a value which depends on the environment.

#ComonadEnv Source

class ComonadEnv :: Type -> (Type -> Type) -> Constraintclass (ComonadAsk e w) <= ComonadEnv e w | w -> e where

The ComonadEnv type class extends ComonadAsk with a function local f x that allows the value of the local context to be modified for the duration of the execution of action x.

An implementation is provided for EnvT.

Laws:

  • ask (local f x) = f (ask x)
  • extract (local _ x) = extract a
  • extend g (local f x) = extend (g <<< local f) x

Members

  • local :: forall a. (e -> e) -> w a -> w a

Instances