Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- class HFunctor sig => Carrier sig h | h -> sig
- class HFunctor sig => Effect sig
- data Fail (m :: * -> *) k
- data Lift sig (m :: * -> *) k
- data NonDet (m :: * -> *) k
- data Random m k
- class Member (sub :: (* -> *) -> * -> *) sup
- data (f :+: g) (m :: * -> *) k
- send :: (Member effect sig, Carrier sig m) => effect m (m a) -> m a
- data Eff carrier a
- interpret :: Carrier sig carrier => Eff carrier a -> carrier a
- data StateC s m a
- data State s (m :: * -> *) k
- data ResumableWithC err m a
- data ResumableC err m a
- data Resumable err (m :: * -> *) k
- data ResourceC m a
- data Resource m k
- data ReaderC r m a
- data Reader r m k
- data RandomC g m a
- data LiftC m a
- runM :: Monad m => Eff (LiftC m) a -> m a
- data FreshC m a
- data Fresh m k
- data FailC m a
- data ErrorC e m a
- data Error exc m k
- data CullC m a
- data Cull m k
- data OnceC f m a
- data AltC f m a
- data CutC m a
- data Cut m k
- data TraceByReturningC m a
- data TraceByIgnoringC m a
- data TraceByPrintingC m a
- data Trace (m :: * -> *) k
- data VoidC a
- data Void (m :: * -> *) k
- run :: Eff VoidC a -> a
- data WriterC w m a
- data Writer w m k
Documentation
class HFunctor sig => Carrier sig h | h -> sig Source #
The class of carriers (results) for algebras (effect handlers) over signatures (effects), whose actions are given by the ret
and eff
methods.
Instances
class HFunctor sig => Effect sig 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.
Instances
Effect Fail Source # | |
Effect NonDet Source # | |
Effect Random Source # | |
Effect Resource Source # | |
Effect Fresh Source # | |
Effect Cull Source # | |
Effect Cut Source # | |
Effect Trace Source # | |
Effect Void Source # | |
Functor sig => Effect (Lift sig) Source # | |
Effect (State s) Source # | |
Effect (Resumable err) Source # | |
Effect (Reader r) Source # | |
Effect (Error exc) Source # | |
Effect (Writer w) Source # | |
(Effect l, Effect r) => Effect (l :+: r) Source # | |
data NonDet (m :: * -> *) k Source #
Instances
Effect NonDet Source # | |
HFunctor NonDet Source # | |
Functor (NonDet m) Source # | |
(Alternative m, Carrier sig m, Effect sig, Monad m) => Carrier (Cull :+: (NonDet :+: sig)) (CullC m) Source # | |
(Alternative m, Carrier sig m, Effect sig, Monad m) => Carrier (Cut :+: (NonDet :+: sig)) (CutC m) Source # | |
(Alternative f, Carrier sig m, Effect sig, Traversable f, Monad f, Monad m) => Carrier (NonDet :+: sig) (OnceC f m) Source # | |
(Alternative f, Monad f, Traversable f, Carrier sig m, Effect sig, Applicative m) => Carrier (NonDet :+: sig) (AltC f m) Source # | |
data (f :+: g) (m :: * -> *) k infixr 4 Source #
Instances
send :: (Member effect sig, Carrier sig m) => effect m (m a) -> m a Source #
Construct a request for an effect to be interpreted by some handler later on.
Instances
Carrier sig carrier => Carrier sig (Eff carrier) Source # | |
Monad (Eff carrier) Source # | |
Functor (Eff carrier) Source # | |
(Member Fail sig, Carrier sig carrier) => MonadFail (Eff carrier) Source # | |
Defined in Control.Effect.Internal | |
Applicative (Eff carrier) Source # | |
Defined in Control.Effect.Internal | |
(Member (Lift IO) sig, Carrier sig carrier) => MonadIO (Eff carrier) Source # | |
Defined in Control.Effect.Internal | |
(Member NonDet sig, Carrier sig carrier) => Alternative (Eff carrier) Source # | Run computations nondeterministically. run (runNonDet empty) == [] run (runNonDet empty) == Nothing run (runNonDet (pure a <|> pure b)) == [a, b] run (runNonDet (pure a <|> pure b)) == Just a Associativity: run (runNonDet ((pure a <|> pure b) <|> pure c)) == (run (runNonDet (pure a <|> (pure b <|> pure c))) :: [Integer]) run (runNonDet ((pure a <|> pure b) <|> pure c)) == (run (runNonDet (pure a <|> (pure b <|> pure c))) :: Maybe Integer) Left-identity: run (runNonDet (empty <|> pure b)) == (run (runNonDet (pure b)) :: [Integer]) run (runNonDet (empty <|> pure b)) == (run (runNonDet (pure b)) :: Maybe Integer) Right-identity: run (runNonDet (pure a <|> empty)) == (run (runNonDet (pure a)) :: [Integer]) run (runNonDet (pure a <|> empty)) == (run (runNonDet (pure a)) :: Maybe Integer) |
(Member NonDet sig, Carrier sig carrier) => MonadPlus (Eff carrier) Source # | |
(Member Random sig, Carrier sig carrier) => MonadInterleave (Eff carrier) Source # | |
Defined in Control.Effect.Internal interleave :: Eff carrier a -> Eff carrier a # | |
(Member Random sig, Carrier sig carrier) => MonadRandom (Eff carrier) Source # | |
Defined in Control.Effect.Internal getRandomR :: Random a => (a, a) -> Eff carrier a # getRandom :: Random a => Eff carrier a # getRandomRs :: Random a => (a, a) -> Eff carrier [a] # getRandoms :: Random a => Eff carrier [a] # |
data ResumableWithC err m a Source #
Instances
(Carrier sig m, Monad m) => Carrier (Resumable err :+: sig) (ResumableWithC err m) Source # | |
Defined in Control.Effect.Resumable ret :: a -> ResumableWithC err m a Source # eff :: (Resumable err :+: sig) (ResumableWithC err m) (ResumableWithC err m a) -> ResumableWithC err m a Source # |
data ResumableC err m a Source #
Instances
(Carrier sig m, Effect sig) => Carrier (Resumable err :+: sig) (ResumableC err m) Source # | |
Defined in Control.Effect.Resumable ret :: a -> ResumableC err m a Source # eff :: (Resumable err :+: sig) (ResumableC err m) (ResumableC err m a) -> ResumableC err m a Source # |
data Resumable err (m :: * -> *) k Source #
Errors which can be resumed with values of some existentially-quantified type.
Instances
Effect (Resumable err) Source # | |
HFunctor (Resumable err) Source # | |
Functor (Resumable err m) Source # | |
(Carrier sig m, Monad m) => Carrier (Resumable err :+: sig) (ResumableWithC err m) Source # | |
Defined in Control.Effect.Resumable ret :: a -> ResumableWithC err m a Source # eff :: (Resumable err :+: sig) (ResumableWithC err m) (ResumableWithC err m a) -> ResumableWithC err m a Source # | |
(Carrier sig m, Effect sig) => Carrier (Resumable err :+: sig) (ResumableC err m) Source # | |
Defined in Control.Effect.Resumable ret :: a -> ResumableC err m a Source # eff :: (Resumable err :+: sig) (ResumableC err m) (ResumableC err m a) -> ResumableC err m a Source # |
data TraceByReturningC m a Source #
Instances
(Carrier sig m, Effect sig) => Carrier (Trace :+: sig) (TraceByReturningC m) Source # | |
Defined in Control.Effect.Trace ret :: a -> TraceByReturningC m a Source # eff :: (Trace :+: sig) (TraceByReturningC m) (TraceByReturningC m a) -> TraceByReturningC m a Source # |
data TraceByIgnoringC m a Source #
Instances
Carrier sig m => Carrier (Trace :+: sig) (TraceByIgnoringC m) Source # | |
Defined in Control.Effect.Trace ret :: a -> TraceByIgnoringC m a Source # eff :: (Trace :+: sig) (TraceByIgnoringC m) (TraceByIgnoringC m a) -> TraceByIgnoringC m a Source # |
data TraceByPrintingC m a Source #
Instances
(MonadIO m, Carrier sig m) => Carrier (Trace :+: sig) (TraceByPrintingC m) Source # | |
Defined in Control.Effect.Trace ret :: a -> TraceByPrintingC m a Source # eff :: (Trace :+: sig) (TraceByPrintingC m) (TraceByPrintingC m a) -> TraceByPrintingC m a Source # |
data Trace (m :: * -> *) k Source #
Instances
Effect Trace Source # | |
HFunctor Trace Source # | |
Functor (Trace m) Source # | |
(Carrier sig m, Effect sig) => Carrier (Trace :+: sig) (TraceByReturningC m) Source # | |
Defined in Control.Effect.Trace ret :: a -> TraceByReturningC m a Source # eff :: (Trace :+: sig) (TraceByReturningC m) (TraceByReturningC m a) -> TraceByReturningC m a Source # | |
Carrier sig m => Carrier (Trace :+: sig) (TraceByIgnoringC m) Source # | |
Defined in Control.Effect.Trace ret :: a -> TraceByIgnoringC m a Source # eff :: (Trace :+: sig) (TraceByIgnoringC m) (TraceByIgnoringC m a) -> TraceByIgnoringC m a Source # | |
(MonadIO m, Carrier sig m) => Carrier (Trace :+: sig) (TraceByPrintingC m) Source # | |
Defined in Control.Effect.Trace ret :: a -> TraceByPrintingC m a Source # eff :: (Trace :+: sig) (TraceByPrintingC m) (TraceByPrintingC m a) -> TraceByPrintingC m a Source # |
A space-efficient carrier for Writer
effects.
This is based on a post Gabriel Gonzalez made to the Haskell mailing list: https://mail.haskell.org/pipermail/libraries/2013-March/019528.html
Note that currently, the constant-space behaviour observed there only occurs when using WriterC
and VoidC
without Eff
wrapping them. See the benchmark
component for details.