Modulecomonad-5.0.9Haskell2010
Control.Comonad.Trans.Env
The environment comonad holds a value along with some retrievable context.
This module specifies the environment comonad transformer (aka coreader), which is left adjoint to the reader comonad.
The following sets up an experiment that retains its initial value in the background:
let initial = env 0 0Extract simply retrieves the value:
extract initial0
Play around with the value, in our case producing a negative value:
let experiment = fmap (+ 10) initialextract experiment10
Oh noes, something went wrong, 10 isn't very negative! Better restore the initial value using the default:
let initialRestored = experiment =>> askextract initialRestored0
- 2 types
- 7 values
- Packagecomonad-5.0.9
- Exports9
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceEnv.hs
The strict environment comonad
3 declarationsCreate an Env using an environment and a value
The strict environment comonad transformer
3 declarationsConstructors
EnvT e (w a)
Instances12ComonadEnv, ComonadStore, ComonadTraced, ComonadTrans, ComonadHoist, Functor, …
Comonad w => ComonadEnv e (EnvT e w)Defined in comonad-5.0.9 · Control.Comonad.Env.ClassComonadStore s w => ComonadStore s (EnvT e w)Defined in comonad-5.0.9 · Control.Comonad.Store.ClassComonadTraced m w => ComonadTraced m (EnvT e w)Defined in comonad-5.0.9 · Control.Comonad.Traced.ClassComonadTrans (EnvT e)Defined in comonad-5.0.9 · Control.Comonad.Trans.EnvComonadHoist (EnvT e)Defined in comonad-5.0.9 · Control.Comonad.Trans.EnvFunctor w => Functor (EnvT e w)Defined in comonad-5.0.9 · Control.Comonad.Trans.Env(Monoid e, Applicative m) => Applicative (EnvT e m)Defined in comonad-5.0.9 · Control.Comonad.Trans.EnvFoldable w => Foldable (EnvT e w)Defined in comonad-5.0.9 · Control.Comonad.Trans.EnvTraversable w => Traversable (EnvT e w)Defined in comonad-5.0.9 · Control.Comonad.Trans.EnvComonad w => Comonad (EnvT e w)Defined in comonad-5.0.9 · Control.Comonad.Trans.Env(Semigroup e, ComonadApply w) => ComonadApply (EnvT e w)Defined in comonad-5.0.9 · Control.Comonad.Trans.Env(Data e, Typeable w, Data (w a), Data a) => Data (EnvT e w a)Defined in comonad-5.0.9 · Control.Comonad.Trans.Env
Gets rid of the environment. This differs from extract in that it will not continue extracting the value from the contained comonad.
Combinators
3 declarationsRetrieves the environment.
Like ask, but modifies the resulting value with a function.
asks = f . askModifies the environment using the specified function.