Module

Control.Comonad.Env

Package
purescript-transformers
Repository
purescript/purescript-transformers

This module defines the Env comonad.

#Env Source

type Env e = EnvT e Identity

The Env comonad is a synonym for the EnvT comonad transformer, applied to the Identity monad.

#runEnv Source

runEnv :: forall a e. Env e a -> Tuple e a

Unwrap a value in the Env comonad.

#withEnv Source

withEnv :: forall a e2 e1. (e1 -> e2) -> Env e1 a -> Env e2 a

Change the environment type in an Env computation.

#mapEnv Source

mapEnv :: forall b a e. (a -> b) -> Env e a -> Env e b

Change the data type in an Env computation.

#env Source

env :: forall a e. e -> a -> Env e a

Create a value in context in the Env comonad.

Re-exports from Control.Comonad.Env.Class

#ComonadEnv Source

class (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

#ask

ask :: forall e w a. ComonadAsk e w => w a -> e

#asks Source

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

Get a value which depends on the environment.

Re-exports from Control.Comonad.Env.Trans

#EnvT Source

newtype EnvT e w a

The environment comonad transformer.

This comonad transformer extends the context of a value in the base comonad with a global environment of type e.

The ComonadEnv type class describes the operations supported by this comonad.

Constructors

Instances

#withEnvT Source

withEnvT :: forall a w e2 e1. (e1 -> e2) -> EnvT e1 w a -> EnvT e2 w a

Change the environment type in an EnvT context.

#runEnvT Source

runEnvT :: forall a w e. EnvT e w a -> Tuple e (w a)

Unwrap a value in the EnvT comonad.

#mapEnvT Source

mapEnvT :: forall b a w2 w1 e. (w1 a -> w2 b) -> EnvT e w1 a -> EnvT e w2 b

Change the underlying comonad and data type in an EnvT context.