Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- class HFunctor h where
- class HFunctor sig => Effect sig where
- class (HFunctor sig, Monad m) => Carrier sig m | m -> 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))
- interpret :: carrier a -> carrier a
Documentation
class HFunctor h where Source #
fmap' :: (a -> b) -> h m a -> h m b Source #
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 Source #
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 Source #
Higher-order functor map of a natural transformation over higher-order positions within the effect.
Instances
HFunctor Pure Source # | |
HFunctor Resource Source # | |
HFunctor Random Source # | |
HFunctor NonDet Source # | |
HFunctor Fresh Source # | |
HFunctor Fail Source # | |
HFunctor Cut Source # | |
HFunctor Cull Source # | |
HFunctor Trace Source # | |
HFunctor (State s) Source # | |
HFunctor (Reader r) Source # | |
Functor sig => HFunctor (Lift sig) Source # | |
HFunctor (Error exc) Source # | |
HFunctor (Resumable err) Source # | |
HFunctor (Writer w) Source # | |
(HFunctor l, HFunctor r) => HFunctor (l :+: r) Source # | |
class HFunctor sig => Effect sig where Source #
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.
handle :: Functor f => f () -> (forall x. f (m x) -> n (f x)) -> sig m (m a) -> sig n (n (f a)) Source #
Handle any effects in a signature by threading the carrier’s state all the way through to the continuation.
Instances
Effect Pure Source # | |
Effect Resource Source # | |
Effect Random Source # | |
Effect NonDet Source # | |
Effect Fresh Source # | |
Effect Fail Source # | |
Effect Cut Source # | |
Effect Cull Source # | |
Effect Trace Source # | |
Effect (State s) Source # | |
Effect (Reader r) Source # | |
Functor sig => Effect (Lift sig) Source # | |
Effect (Error exc) Source # | |
Effect (Resumable err) Source # | |
Effect (Writer w) Source # | |
(Effect l, Effect r) => Effect (l :+: r) Source # | |
class (HFunctor sig, Monad m) => Carrier sig m | m -> sig where Source #
The class of carriers (results) for algebras (effect handlers) over signatures (effects), whose actions are given by the eff
method.
eff :: sig m (m a) -> m a Source #
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) Source #
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) Source #
handleReader :: HFunctor sig => r -> (forall x. f x -> r -> g x) -> sig f (f a) -> sig g (g a) Source #
handleState :: Effect sig => s -> (forall x. f x -> s -> g (s, x)) -> sig f (f a) -> sig g (g (s, a)) Source #
handleEither :: (Carrier sig g, Effect sig) => (forall x. f x -> g (Either e x)) -> sig f (f a) -> sig g (g (Either e a)) Source #
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)) Source #
Deprecated: Compose carrier types from other carriers and define eff
with handleCoercible instead
Thread a carrier producing values in a Traversable
Monad
(e.g. '[]') through an Effect
.