| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Control.Effect.Carrier
Synopsis
- class HFunctor h where
- class HFunctor sig => Effect sig where
- class HFunctor sig => Carrier sig h | h -> sig where
- handlePure :: HFunctor sig => (forall x. f x -> g x) -> sig f (f a) -> sig g (g a)
- handleCoercible :: (HFunctor sig, Coercible f g) => sig f (f a) -> sig g (g a)
- handleReader :: HFunctor sig => r -> (forall x. f x -> r -> g x) -> sig f (f a) -> sig g (g a)
- handleState :: Effect sig => s -> (forall x. f x -> s -> g (s, x)) -> sig f (f a) -> sig g (g (s, a))
- handleEither :: (Carrier sig g, Effect sig) => (forall x. f x -> g (Either e x)) -> sig f (f a) -> sig g (g (Either e a))
- handleTraversable :: (Effect sig, Applicative g, Monad m, Traversable m) => (forall x. f x -> g (m x)) -> sig f (f a) -> sig g (g (m a))
Documentation
Minimal complete definition
Methods
fmap' :: (a -> b) -> h m a -> h m b #
Functor map. This is required to be fmap.
This can go away once we have quantified constraints.
fmap' :: Functor (h m) => (a -> b) -> h m a -> h m b #
Functor map. This is required to be fmap.
This can go away once we have quantified constraints.
hmap :: (forall x. m x -> n x) -> h m a -> h n a #
Higher-order functor map of a natural transformation over higher-order positions within the effect.
Instances
| HFunctor Fail # | |
| HFunctor NonDet # | |
| HFunctor Random # | |
| HFunctor Resource # | |
| HFunctor Fresh # | |
| HFunctor Cull # | |
| HFunctor Cut # | |
| HFunctor Trace # | |
| HFunctor Void # | |
| Functor sig => HFunctor (Lift sig) # | |
| HFunctor (State s) # | |
| HFunctor (Resumable err) # | |
| HFunctor (Reader r) # | |
| HFunctor (Error exc) # | |
| HFunctor (Writer w) # | |
| (HFunctor l, HFunctor r) => HFunctor (l :+: r) # | |
class HFunctor sig => Effect sig where #
The class of effect types, which must:
- Be functorial in their last two arguments, and
- Support threading effects in higher-order positions through using the carrier’s suspended state.
Methods
handle :: Functor f => f () -> (forall x. f (m x) -> n (f x)) -> sig m (m a) -> sig n (n (f a)) #
Handle any effects in a signature by threading the carrier’s state all the way through to the continuation.
Instances
| Effect Fail # | |
| Effect NonDet # | |
| Effect Random # | |
| Effect Resource # | |
| Effect Fresh # | |
| Effect Cull # | |
| Effect Cut # | |
| Effect Trace # | |
| Effect Void # | |
| Functor sig => Effect (Lift sig) # | |
| Effect (State s) # | |
| Effect (Resumable err) # | |
| Effect (Reader r) # | |
| Effect (Error exc) # | |
| Effect (Writer w) # | |
| (Effect l, Effect r) => Effect (l :+: r) # | |
class HFunctor sig => Carrier sig h | h -> sig where #
The class of carriers (results) for algebras (effect handlers) over signatures (effects), whose actions are given by the ret and eff methods.
Methods
Wrap a return value.
Construct a value in the carrier for an effect signature (typically a sum of a handled effect and any remaining effects).
Instances
handlePure :: HFunctor sig => (forall x. f x -> g x) -> sig f (f a) -> sig g (g a) #
Apply a handler specified as a natural transformation to both higher-order and continuation positions within an HFunctor.
handleCoercible :: (HFunctor sig, Coercible f g) => sig f (f a) -> sig g (g a) #
handleReader :: HFunctor sig => r -> (forall x. f x -> r -> g x) -> sig f (f a) -> sig g (g a) #
Thread a Reader-like carrier through an HFunctor.
handleState :: Effect sig => s -> (forall x. f x -> s -> g (s, x)) -> sig f (f a) -> sig g (g (s, a)) #
Thread a State-like carrier through an Effect.
handleEither :: (Carrier sig g, Effect sig) => (forall x. f x -> g (Either e x)) -> sig f (f a) -> sig g (g (Either e a)) #
handleTraversable :: (Effect sig, Applicative g, Monad m, Traversable m) => (forall x. f x -> g (m x)) -> sig f (f a) -> sig g (g (m a)) #
Thread a carrier producing values in a Traversable Monad (e.g. '[]') through an Effect.