Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Lift sig m k = LiftWith (forall ctx. Functor ctx => ctx () -> (forall a. ctx (m a) -> sig (ctx a)) -> sig (ctx a)) (a -> m k)
- sendM :: (Has (Lift n) sig m, Functor n) => n a -> m a
- liftWith :: Has (Lift n) sig m => (forall ctx. Functor ctx => ctx () -> (forall a. ctx (m a) -> n (ctx a)) -> n (ctx a)) -> m a
- class (HFunctor sig, Monad m) => Algebra sig m | m -> sig
- type Has eff sig m = (Members eff sig, Algebra sig m)
- run :: Identity a -> a
Lift effect
Since: 1.0.0.0
LiftWith (forall ctx. Functor ctx => ctx () -> (forall a. ctx (m a) -> sig (ctx a)) -> sig (ctx a)) (a -> m k) |
sendM :: (Has (Lift n) sig m, Functor n) => n a -> m a Source #
Given a Lift n
constraint in a signature carried by m
, sendM
promotes arbitrary actions of type n a
to m a
. It is spiritually
similar to lift
from the MonadTrans
typeclass.
Since: 1.0.0.0
liftWith :: Has (Lift n) sig m => (forall ctx. Functor ctx => ctx () -> (forall a. ctx (m a) -> n (ctx a)) -> n (ctx a)) -> m a Source #
Run actions in an outer context.
This can be used to provide interoperation with base
functionality like Control.Exception.
:catch
liftWith
$ ctx hdl ->catch
(hdl (m <$ ctx)) (hdl . (<$ ctx) . h)
The higher-order function takes both an initial context, and a handler phrased as the same sort of distributive law as described in the documentation for thread
. This handler takes actions lifted into a context functor, which can be either the initial context, or the derived context produced by handling a previous action.
As with MonadBaseControl
, care must be taken when lifting functions like Control.Exception.
which don’t use the return value of one of their actions, as this can lead to dropped effects.finally
Since: 1.0.0.0
Re-exports
class (HFunctor sig, Monad m) => Algebra sig m | m -> sig Source #
The class of carriers (results) for algebras (effect handlers) over signatures (effects), whose actions are given by the alg
method.
Since: 1.0.0.0
Instances
type Has eff sig m = (Members eff sig, Algebra sig m) Source #
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:
- Due to a problem with recursive type families, this can lead to significantly slower compiles.
- It defeats
ghc
’s warnings for redundant constraints, and thus can lead to a proliferation of redundant constraints as code is changed.