| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Control.Effect.Lift
Contents
Description
Synopsis
- data Lift (sig :: Type -> Type) (m :: Type -> Type) k where
- sendM :: forall n (sig :: (Type -> Type) -> Type -> Type) m a. (Has (Lift n) sig m, Functor n) => n a -> m a
- sendIO :: forall (sig :: (Type -> Type) -> Type -> Type) m a. Has (Lift IO) sig m => IO a -> m a
- liftWith :: forall n (sig :: (Type -> Type) -> Type -> Type) m a. Has (Lift n) sig m => (forall (ctx :: Type -> Type). Functor ctx => Handler ctx m n -> ctx () -> n (ctx a)) -> m a
- class Monad m => Algebra (sig :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) | m -> sig
- type Has (eff :: (Type -> Type) -> Type -> Type) (sig :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) = (Members eff sig, Algebra sig m)
- run :: Identity a -> a
Lift effect
data Lift (sig :: Type -> Type) (m :: Type -> Type) k where Source #
Since: 1.0.0.0
Constructors
| LiftWith :: forall (m :: Type -> Type) (sig :: Type -> Type) k. (forall (ctx :: Type -> Type). Functor ctx => Handler ctx m sig -> ctx () -> sig (ctx k)) -> Lift sig m k |
sendM :: forall n (sig :: (Type -> Type) -> Type -> Type) m a. (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
sendIO :: forall (sig :: (Type -> Type) -> Type -> Type) m a. Has (Lift IO) sig m => IO a -> m a Source #
A type-restricted variant of sendM for IO actions.
This is particularly useful when you have a constraint for the use of Has (Lift IO) sig mliftWith, and want to run an action abstracted over MonadIO. IO has a MonadIO instance, and sendIO’s type restricts the action’s type to IO without further type annotations.
Since: 1.0.2.0
liftWith :: forall n (sig :: (Type -> Type) -> Type -> Type) m a. Has (Lift n) sig m => (forall (ctx :: Type -> Type). Functor ctx => Handler ctx m n -> ctx () -> 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$ \ hdl ctx ->catch(hdl (m <$ ctx)) (hdl . (<$ ctx) . h)
The higher-order function takes both an initial context, and a handler phrased as a distributive law (as described in the documentation for Handler). 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 Monad m => Algebra (sig :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) | 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
Minimal complete definition
Instances
| Algebra Choose NonEmpty Source # | |
| Algebra Empty Maybe Source # | |
| Algebra NonDet [] Source # | |
| Algebra sig m => Algebra sig (Choosing m) Source # | |
| Algebra sig m => Algebra sig (Ap m) Source # | This instance permits effectful actions to be lifted into the mappend <$> act1 <*> (mappend <$> act2 <*> act3) is equivalent to getAp (act1 <> act2 <> act3) Since: 1.0.1.0 |
| Algebra sig m => Algebra sig (Alt m) Source # | This instance permits effectful actions to be lifted into the a <|> b <|> c <|> d is equivalent to getAlt (mconcat [a, b, c, d]) Since: 1.0.1.0 |
| Algebra sig m => Algebra sig (IdentityT m) Source # | |
| Algebra (Lift Identity) Identity Source # | |
| Algebra (Lift IO) IO Source # | |
| Algebra (Error e) (Either e) Source # | |
| Monad m => Algebra (Lift m) (LiftC m) Source # | |
| Monoid w => Algebra (Writer w) ((,) w) Source # | |
| Algebra (Reader r) ((->) r) Source # | |
| Algebra sig m => Algebra (Choose :+: sig) (ChooseC m) Source # | |
| Algebra sig m => Algebra (Cull :+: (NonDet :+: sig)) (CullC m) Source # | |
| Algebra sig m => Algebra (Cut :+: (NonDet :+: sig)) (CutC m) Source # | |
| Algebra sig m => Algebra (Empty :+: sig) (EmptyC m) Source # | |
| Algebra sig m => Algebra (Empty :+: sig) (EmptyC m) Source # | |
| Algebra sig m => Algebra (Empty :+: sig) (MaybeT m) Source # | |
| Algebra sig m => Algebra (Fail :+: sig) (FailC m) Source # | |
| Algebra sig m => Algebra (Fresh :+: sig) (FreshC m) Source # | |
| Algebra sig m => Algebra (Fresh :+: sig) (FreshC m) Source # | |
| Algebra sig m => Algebra (NonDet :+: sig) (NonDetC m) Source # | |
| Algebra sig m => Algebra (Trace :+: sig) (TraceC m) Source # | |
| (MonadIO m, Algebra sig m) => Algebra (Trace :+: sig) (TraceC m) Source # | |
| Algebra sig m => Algebra (Trace :+: sig) (TraceC m) Source # | |
| (Algebra sig m, Monoid w) => Algebra (Accum w :+: sig) (AccumC w m) Source # | |
| (Algebra sig m, Semigroup w, MonadIO m) => Algebra (Accum w :+: sig) (AccumC w m) Source # | |
| (Algebra sig m, Monoid w) => Algebra (Accum w :+: sig) (AccumC w m) Source # | |
| (Algebra sig m, Monoid w) => Algebra (Accum w :+: sig) (AccumT w m) Source # | |
| Algebra sig m => Algebra (Error e :+: sig) (ErrorC e m) Source # | |
| Algebra sig m => Algebra (Error e :+: sig) (ErrorC e m) Source # | |
| Algebra sig m => Algebra (Error e :+: sig) (ExceptT e m) Source # | |
| Algebra sig m => Algebra (Reader r :+: sig) (ReaderC r m) Source # | |
| Algebra sig m => Algebra (Reader r :+: sig) (ReaderT r m) Source # | |
| Algebra sig m => Algebra (State s :+: sig) (StateC s m) Source # | |
| (MonadIO m, Algebra sig m) => Algebra (State s :+: sig) (StateC s m) Source # | |
| Algebra sig m => Algebra (State s :+: sig) (StateC s m) Source # | |
| Algebra sig m => Algebra (State s :+: sig) (StateC s m) Source # | |
| Algebra sig m => Algebra (State s :+: sig) (StateT s m) Source # | |
| Algebra sig m => Algebra (State s :+: sig) (StateT s m) Source # | |
| Algebra sig m => Algebra (Throw e :+: sig) (ThrowC e m) Source # | |
| (Algebra sig m, Monoid w) => Algebra (Writer w :+: sig) (WriterC w m) Source # | |
| (Monoid w, Algebra sig m) => Algebra (Writer w :+: sig) (WriterC w m) Source # | |
| (Algebra sig m, Monoid w) => Algebra (Writer w :+: sig) (WriterT w m) Source # | |
| (Algebra sig m, Monoid w) => Algebra (Writer w :+: sig) (WriterT w m) Source # | |
| (Algebra sig m, Monoid w) => Algebra (Writer w :+: sig) (WriterT w m) Source # | |
| (Reifies s (Interpreter eff m), Algebra sig m) => Algebra (eff :+: sig) (InterpretC s eff m) Source # | |
Defined in Control.Carrier.Interpret Methods alg :: forall ctx (n :: Type -> Type) a. Functor ctx => Handler ctx n (InterpretC s eff m) -> (eff :+: sig) n a -> ctx () -> InterpretC s eff m (ctx a) Source # | |
| Algebra (eff :+: sig) (sub m) => Algebra (Labelled label eff :+: sig) (Labelled label sub m) Source # | |
| (Algebra sig m, Monoid w) => Algebra (Reader r :+: (Writer w :+: (State s :+: sig))) (RWST r w s m) Source # | |
| (Algebra sig m, Monoid w) => Algebra (Reader r :+: (Writer w :+: (State s :+: sig))) (RWST r w s m) Source # | |
| (Algebra sig m, Monoid w) => Algebra (Reader r :+: (Writer w :+: (State s :+: sig))) (RWST r w s m) Source # | |
| (LabelledMember label sub sig, Algebra sig m) => Algebra (sub :+: sig) (UnderLabel label sub m) Source # | |
Defined in Control.Effect.Labelled Methods alg :: forall ctx (n :: Type -> Type) a. Functor ctx => Handler ctx n (UnderLabel label sub m) -> (sub :+: sig) n a -> ctx () -> UnderLabel label sub m (ctx a) Source # | |
type Has (eff :: (Type -> Type) -> Type -> Type) (sig :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) = (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.
Since: 1.0.0.0