HORIZON HASKELLDocslts/ghc-10.0.x8c2f8e82026-10-19Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8c2f8e8 · 2026-10-19

Modulefused-effects-1.1.2.7Haskell2010

Control.Effect.Reader

An effect providing access to an immutable (but locally-modifiable) context value.

This effect is similar to the traditional MonadReader typeclass, though it allows the presence of multiple Reader t effects.

Predefined carriers:

  • 2 types
  • 1 class
  • 4 values

Reader effect

4 declarations
datadata Reader r (m :: Type -> Type) k where
#

Constructors

Instances6Algebra
valueask :: Has (Reader r) sig m => m r
#

Retrieve the environment value.

runReader a (ask >>= k) = runReader a (k a)
valueasks :: Has (Reader r) sig m => (r -> a) -> m a
#

Project a function out of the current environment value.

asks f = fmap f ask
valuelocal :: Has (Reader r) sig m => (r -> r) -> m a -> m a
#

Run a computation with an environment value locally modified by the passed function.

runReader a (local f m) = runReader (f a) m

Re-exports

3 declarations
classclass Monad m => Algebra (sig :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) | m -> sig where
#

The class of carriers (results) for algebras (effect handlers) over signatures (effects), whose actions are given by the alg method.

Instances53Algebra, …
typetype Has (eff :: (Type -> Type) -> Type -> Type) (sig :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) = (Members eff sig, Algebra sig m)
#

m is a carrier for sig containing eff.

Note that if eff is a sum, it will be decomposed into multiple Member constraints. While this technically allows one to combine multiple unrelated effects into a single Has constraint, doing so has two significant drawbacks:

  1. Due to a problem with recursive type families, this can lead to significantly slower compiles.

  2. It defeats ghc’s warnings for redundant constraints, and thus can lead to a proliferation of redundant constraints as code is changed.

valuerun :: Identity a -> a
#

Run an action exhausted of effects to produce its final result value.