comonad-5: Comonads

Copyright(C) 2008-2014 Edward Kmett
LicenseBSD-style (see the file LICENSE)
MaintainerEdward Kmett <ekmett@gmail.com>
Stabilityexperimental
Portabilitynon-portable (fundeps, MPTCs)
Safe HaskellSafe
LanguageHaskell2010

Control.Comonad.Env

Contents

Description

The Env comonad (aka the Coreader, Environment, or Product comonad)

A co-Kleisli arrow in the Env comonad is isomorphic to a Kleisli arrow in the reader monad.

(a -> e -> m) ~ (a, e) -> m ~ Env e a -> m

Synopsis

ComonadEnv class

class Comonad w => ComonadEnv e w | w -> e where Source

Methods

ask :: w a -> e Source

asks :: ComonadEnv e w => (e -> e') -> w a -> e' Source

local :: (e -> e') -> EnvT e w a -> EnvT e' w a Source

Modifies the environment using the specified function.

The Env comonad

type Env e = EnvT e Identity Source

env :: e -> a -> Env e a Source

Create an Env using an environment and a value

runEnv :: Env e a -> (e, a) Source

The EnvT comonad transformer

data EnvT e w a Source

Constructors

EnvT e (w a) 

runEnvT :: EnvT e w a -> (e, w a) Source

Re-exported modules