comonad-4.0: Comonads

Portability | non-portable (fundeps, MPTCs)
Stability | experimental
Maintainer | Edward Kmett <ekmett@gmail.com>
Safe Haskell | Trustworthy

Control.Comonad.Env

Contents

- ComonadEnv class
- The Env comonad
- The EnvT comonad transformer
- Re-exported modules

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

- class Comonad w => ComonadEnv e w | w -> e where
  - ask :: w a -> e
- asks :: ComonadEnv e w => (e -> e') -> w a -> e'
- local :: (e -> e') -> EnvT e w a -> EnvT e' w a
- type Env e = EnvT e Identity
- env :: e -> a -> Env e a
- runEnv :: Env e a -> (e, a)
- data EnvT e w a = EnvT e (w a)
- runEnvT :: EnvT e w a -> (e, w a)
- module Control.Comonad
- module Control.Comonad.Trans.Class

# ComonadEnv class

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

Methods

ask :: w a -> eSource

Instances

ComonadEnv e w => ComonadEnv e (IdentityT w) |
ComonadEnv e ((,) e) |
(ComonadEnv e w, Monoid m) => ComonadEnv e (TracedT m w) |
ComonadEnv e w => ComonadEnv e (StoreT t w) |
Comonad w => ComonadEnv e (EnvT e w) |

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

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

Modifies the environment using the specified function.

# The Env comonad

type Env e = EnvT e Identity Source

env :: e -> a -> Env e aSource

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) |

Instances

Comonad w => ComonadEnv e (EnvT e w) |
ComonadStore s w => ComonadStore s (EnvT e w) |
ComonadTraced m w => ComonadTraced m (EnvT e w) |
ComonadTrans (EnvT e) |
ComonadHoist (EnvT e) |
Functor w => Functor (EnvT e w) |
(Typeable s, Typeable1 w) => Typeable1 (EnvT s w) |
Foldable w => Foldable (EnvT e w) |
Traversable w => Traversable (EnvT e w) |
(Semigroup e, ComonadApply w) => ComonadApply (EnvT e w) |
Comonad w => Comonad (EnvT e w) |
(Data e, Typeable1 w, Data (w a), Data a) => Data (EnvT e w a) |
(Typeable s, Typeable1 w, Typeable a) => Typeable (EnvT s w a) |

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

# Re-exported modules

module Control.Comonad

module Control.Comonad.Trans.Class