Control.Comonad.Env

comonad-5.0.9: Comonads

Copyright | (C) 2008-2014 Edward Kmett
License | BSD-style (see the file LICENSE)
Maintainer | Edward Kmett <ekmett@gmail.com>
Stability | experimental
Portability | non-portable (fundeps, MPTCs)
Safe Haskell | Safe
Language | Haskell2010

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 :: Type -> Type) | w -> e where
  - ask :: w a -> e
- asks :: ComonadEnv e w => (e -> e') -> w a -> e'
- local :: forall e e' (w :: Type -> Type) a. (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 :: Type -> Type) 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 :: Type -> Type) | w -> e where #

Methods

ask :: w a -> e #

#### Instances

Instances details

ComonadEnv e (Arg e) # |
Instance details Defined in Control.Comonad.Env.Class Methods ask :: Arg e a -> e #
ComonadEnv e ((,) e) # |
Instance details Defined in Control.Comonad.Env.Class Methods ask :: (e, a) -> e #
Comonad w => ComonadEnv e (EnvT e w) # |
Instance details Defined in Control.Comonad.Env.Class Methods ask :: EnvT e w a -> e #
ComonadEnv e w => ComonadEnv e (StoreT t w) # |
Instance details Defined in Control.Comonad.Env.Class Methods ask :: StoreT t w a -> e #
(ComonadEnv e w, Monoid m) => ComonadEnv e (TracedT m w) # |
Instance details Defined in Control.Comonad.Env.Class Methods ask :: TracedT m w a -> e #
ComonadEnv e w => ComonadEnv e (IdentityT w) # |
Instance details Defined in Control.Comonad.Env.Class Methods ask :: IdentityT w a -> e #

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

local :: forall e e' (w :: Type -> Type) a. (e -> e') -> EnvT e w a -> EnvT e' w a #

Modifies the environment using the specified function.

# The Env comonad

type Env e = EnvT e Identity #

env :: e -> a -> Env e a #

Create an Env using an environment and a value

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

# The EnvT comonad transformer

data EnvT e (w :: Type -> Type) a #

Constructors

EnvT e (w a) |

#### Instances

Instances details

Comonad w => ComonadEnv e (EnvT e w) # |
Instance details Defined in Control.Comonad.Env.Class Methods ask :: EnvT e w a -> e #
ComonadStore s w => ComonadStore s (EnvT e w) # |
Instance details Defined in Control.Comonad.Store.Class Methods pos :: EnvT e w a -> s # peek :: s -> EnvT e w a -> a # peeks :: (s -> s) -> EnvT e w a -> a # seek :: s -> EnvT e w a -> EnvT e w a # seeks :: (s -> s) -> EnvT e w a -> EnvT e w a # experiment :: Functor f => (s -> f s) -> EnvT e w a -> f a #
ComonadTraced m w => ComonadTraced m (EnvT e w) # |
Instance details Defined in Control.Comonad.Traced.Class Methods trace :: m -> EnvT e w a -> a #
ComonadHoist (EnvT e) # |
Instance details Defined in Control.Comonad.Trans.Env Methods cohoist :: (Comonad w, Comonad v) => (forall x. w x -> v x) -> EnvT e w a -> EnvT e v a #
ComonadTrans (EnvT e) # |
Instance details Defined in Control.Comonad.Trans.Env Methods lower :: Comonad w => EnvT e w a -> w a #
Comonad w => Comonad (EnvT e w) # |
Instance details Defined in Control.Comonad.Trans.Env Methods extract :: EnvT e w a -> a # duplicate :: EnvT e w a -> EnvT e w (EnvT e w a) # extend :: (EnvT e w a -> b) -> EnvT e w a -> EnvT e w b #
(Semigroup e, ComonadApply w) => ComonadApply (EnvT e w) # |
Instance details Defined in Control.Comonad.Trans.Env Methods (<@>) :: EnvT e w (a -> b) -> EnvT e w a -> EnvT e w b # (@>) :: EnvT e w a -> EnvT e w b -> EnvT e w b # (<@) :: EnvT e w a -> EnvT e w b -> EnvT e w a #
(Monoid e, Applicative m) => Applicative (EnvT e m) # |
Instance details Defined in Control.Comonad.Trans.Env Methods pure :: a -> EnvT e m a # (<*>) :: EnvT e m (a -> b) -> EnvT e m a -> EnvT e m b # liftA2 :: (a -> b -> c) -> EnvT e m a -> EnvT e m b -> EnvT e m c # (*>) :: EnvT e m a -> EnvT e m b -> EnvT e m b # (<*) :: EnvT e m a -> EnvT e m b -> EnvT e m a #
Functor w => Functor (EnvT e w) # |
Instance details Defined in Control.Comonad.Trans.Env Methods fmap :: (a -> b) -> EnvT e w a -> EnvT e w b # (<$) :: a -> EnvT e w b -> EnvT e w a #
Foldable w => Foldable (EnvT e w) # |
Instance details Defined in Control.Comonad.Trans.Env Methods fold :: Monoid m => EnvT e w m -> m # foldMap :: Monoid m => (a -> m) -> EnvT e w a -> m # foldMap' :: Monoid m => (a -> m) -> EnvT e w a -> m # foldr :: (a -> b -> b) -> b -> EnvT e w a -> b # foldr' :: (a -> b -> b) -> b -> EnvT e w a -> b # foldl :: (b -> a -> b) -> b -> EnvT e w a -> b # foldl' :: (b -> a -> b) -> b -> EnvT e w a -> b # foldr1 :: (a -> a -> a) -> EnvT e w a -> a # foldl1 :: (a -> a -> a) -> EnvT e w a -> a # toList :: EnvT e w a -> [a] # null :: EnvT e w a -> Bool # length :: EnvT e w a -> Int # elem :: Eq a => a -> EnvT e w a -> Bool # maximum :: Ord a => EnvT e w a -> a # minimum :: Ord a => EnvT e w a -> a # sum :: Num a => EnvT e w a -> a # product :: Num a => EnvT e w a -> a #
Traversable w => Traversable (EnvT e w) # |
Instance details Defined in Control.Comonad.Trans.Env Methods traverse :: Applicative f => (a -> f b) -> EnvT e w a -> f (EnvT e w b) # sequenceA :: Applicative f => EnvT e w (f a) -> f (EnvT e w a) # mapM :: Monad m => (a -> m b) -> EnvT e w a -> m (EnvT e w b) # sequence :: Monad m => EnvT e w (m a) -> m (EnvT e w a) #
(Data e, Typeable w, Data (w a), Data a) => Data (EnvT e w a) # |
Instance details Defined in Control.Comonad.Trans.Env Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> EnvT e w a -> c (EnvT e w a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (EnvT e w a) # toConstr :: EnvT e w a -> Constr # dataTypeOf :: EnvT e w a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (EnvT e w a)) # dataCast2 :: Typeable t => (forall d e0. (Data d, Data e0) => c (t d e0)) -> Maybe (c (EnvT e w a)) # gmapT :: (forall b. Data b => b -> b) -> EnvT e w a -> EnvT e w a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> EnvT e w a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> EnvT e w a -> r # gmapQ :: (forall d. Data d => d -> u) -> EnvT e w a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> EnvT e w a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> EnvT e w a -> m (EnvT e w a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> EnvT e w a -> m (EnvT e w a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> EnvT e w a -> m (EnvT e w a) #

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

# Re-exported modules

module Control.Comonad

module Control.Comonad.Trans.Class