Module

Control.Comonad.Env

Package
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 e a. Env e a -> Tuple e a

Unwrap a value in the Env comonad.

#withEnv Source

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

Change the environment type in an Env computation.

#mapEnv Source

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

Change the data type in an Env computation.

#env Source

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

Create a value in context in the Env comonad.

Re-exports from Control.Comonad.Env.Class

#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

#ask Source

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

#asks Source

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

Get a value which depends on the environment.

Re-exports from Control.Comonad.Env.Trans

#EnvT Source

newtype EnvT :: forall k. Type -> (k -> Type) -> k -> Typenewtype 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 e1 e2 w a. (e1 -> e2) -> EnvT e1 w a -> EnvT e2 w a

Change the environment type in an EnvT context.

#runEnvT Source

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

Unwrap a value in the EnvT comonad.

#mapEnvT Source

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

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