Copyright | (c) 2023 Sayo Koyoneda |
---|---|
License | MPL-2.0 (see the file LICENSE) |
Maintainer | ymdfield@outlook.jp |
Safe Haskell | None |
Language | GHC2021 |
Data.Effect.Reader
Description
Effects that can be used to hold environmental values in the context.
Environmental values are immutable and do not change across procedures, but you
can modify the value within a local scope using the local
operation.
Synopsis
- data Ask r a where
- data Local r (f :: Type -> Type) a where
- type LAsk r = LiftFOE (Ask r)
- pattern LAsk :: forall a r f. () => (a ~ r, ()) => LiftFOE (Ask r) f a
- ask :: SendFOE (Ask r) f => f r
- ask' :: forall {k} (tag :: k) r f. SendFOE (Tag (Ask r) tag) f => f r
- ask'' :: forall {k} (key :: k) r f. SendFOEBy key (Ask r) f => f r
- local :: forall r a f. SendHOE (Local r) f => (r -> r) -> f a -> f a
- local' :: forall {k} (tag :: k) r a f. SendHOE (TagH (Local r) tag) f => (r -> r) -> f a -> f a
- local'' :: forall {k} (key :: k) r a f. SendHOEBy key (Local r) f => (r -> r) -> f a -> f a
- asks :: (Ask r <: f, Functor f) => (r -> a) -> f a
Documentation
An effect that holds a value of type r
in the context (environment).
data Local r (f :: Type -> Type) a where Source #
An effect that locally modifies the value held in the environment.
Constructors
Local | Locally modifies the value held in the environment. |
ask' :: forall {k} (tag :: k) r f. SendFOE (Tag (Ask r) tag) f => f r Source #
Obtain a value from the environment.
ask'' :: forall {k} (key :: k) r f. SendFOEBy key (Ask r) f => f r Source #
Obtain a value from the environment.
Arguments
:: forall r a f. SendHOE (Local r) f | |
=> (r -> r) | |
-> f a | The local scope where the modification is applied. |
-> f a |
Locally modifies the value held in the environment.
Arguments
:: forall {k} (tag :: k) r a f. SendHOE (TagH (Local r) tag) f | |
=> (r -> r) | |
-> f a | The local scope where the modification is applied. |
-> f a |
Locally modifies the value held in the environment.