Module

Control.Comonad.Env.Class

This module defines the ComonadEnv type class and its instances.

#ComonadAsk

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

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

Get a value which depends on the environment.

#ComonadEnv

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

Modules