fused-effects-1.0.0.0: A fast, flexible, fused effect system.

Safe HaskellNone
LanguageHaskell2010

Control.Algebra

Contents

Description

The Algebra class is the mechanism with which effects are interpreted.

An instance of the Algebra class defines an interpretation of an effect signature atop a given monad.

Since: 1.0.0.0

Synopsis

Documentation

class (HFunctor sig, Monad m) => Algebra sig m | m -> sig where 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

Methods

alg :: sig 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
Algebra Choose NonEmpty Source # 
Instance details

Defined in Control.Algebra

Methods

alg :: Choose NonEmpty a -> NonEmpty a Source #

Algebra Empty Maybe Source # 
Instance details

Defined in Control.Algebra

Methods

alg :: Empty Maybe a -> Maybe a Source #

Algebra NonDet [] Source # 
Instance details

Defined in Control.Algebra

Methods

alg :: NonDet [] a -> [a] Source #

Algebra sig m => Algebra sig (IdentityT m) Source # 
Instance details

Defined in Control.Algebra

Methods

alg :: sig (IdentityT m) a -> IdentityT m a Source #

Algebra (Lift IO) IO Source # 
Instance details

Defined in Control.Algebra

Methods

alg :: Lift IO IO a -> IO a Source #

Algebra (Lift Identity) Identity Source # 
Instance details

Defined in Control.Algebra

Monad m => Algebra (Lift m) (LiftC m) Source # 
Instance details

Defined in Control.Carrier.Lift

Methods

alg :: Lift m (LiftC m) a -> LiftC m a Source #

Algebra (Error e) (Either e) Source # 
Instance details

Defined in Control.Algebra

Methods

alg :: Error e (Either e) a -> Either e a Source #

Monoid w => Algebra (Writer w) ((,) w) Source # 
Instance details

Defined in Control.Algebra

Methods

alg :: Writer w ((,) w) a -> (w, a) Source #

Algebra (Reader r) ((->) r :: Type -> Type) Source # 
Instance details

Defined in Control.Algebra

Methods

alg :: Reader r ((->) r) a -> r -> a Source #

(Algebra sig m, Effect sig) => Algebra (Choose :+: sig) (ChooseC m) Source # 
Instance details

Defined in Control.Carrier.Choose.Church

Methods

alg :: (Choose :+: sig) (ChooseC m) a -> ChooseC m a Source #

(Algebra sig m, Effect sig) => Algebra (Empty :+: sig) (EmptyC m) Source # 
Instance details

Defined in Control.Carrier.Empty.Maybe

Methods

alg :: (Empty :+: sig) (EmptyC m) a -> EmptyC m a Source #

(Algebra sig m, Effect sig) => Algebra (NonDet :+: sig) (NonDetC m) Source # 
Instance details

Defined in Control.Carrier.NonDet.Church

Methods

alg :: (NonDet :+: sig) (NonDetC m) a -> NonDetC m a Source #

(MonadIO m, Algebra sig m) => Algebra (Trace :+: sig) (TraceC m) Source # 
Instance details

Defined in Control.Carrier.Trace.Printing

Methods

alg :: (Trace :+: sig) (TraceC m) a -> TraceC m a Source #

Algebra sig m => Algebra (Trace :+: sig) (TraceC m) Source # 
Instance details

Defined in Control.Carrier.Trace.Ignoring

Methods

alg :: (Trace :+: sig) (TraceC m) a -> TraceC m a Source #

(Algebra sig m, Effect sig) => Algebra (Trace :+: sig) (TraceC m) Source # 
Instance details

Defined in Control.Carrier.Trace.Returning

Methods

alg :: (Trace :+: sig) (TraceC m) a -> TraceC m a Source #

(Algebra sig m, Effect sig) => Algebra (Fail :+: sig) (FailC m) Source # 
Instance details

Defined in Control.Carrier.Fail.Either

Methods

alg :: (Fail :+: sig) (FailC m) a -> FailC m a Source #

(Algebra sig m, Effect sig) => Algebra (Fresh :+: sig) (FreshC m) Source # 
Instance details

Defined in Control.Carrier.Fresh.Strict

Methods

alg :: (Fresh :+: sig) (FreshC m) a -> FreshC m a Source #

(Algebra sig m, Effect sig) => Algebra (Cut :+: (NonDet :+: sig)) (CutC m) Source # 
Instance details

Defined in Control.Carrier.Cut.Church

Methods

alg :: (Cut :+: (NonDet :+: sig)) (CutC m) a -> CutC m a Source #

(Algebra sig m, Effect sig) => Algebra (Cull :+: (NonDet :+: sig)) (CullC m) Source # 
Instance details

Defined in Control.Carrier.Cull.Church

Methods

alg :: (Cull :+: (NonDet :+: sig)) (CullC m) a -> CullC m a Source #

Algebra sig m => Algebra (Reader r :+: sig) (ReaderT r m) Source # 
Instance details

Defined in Control.Algebra

Methods

alg :: (Reader r :+: sig) (ReaderT r m) a -> ReaderT r m a Source #

Algebra sig m => Algebra (Reader r :+: sig) (ReaderC r m) Source # 
Instance details

Defined in Control.Carrier.Reader

Methods

alg :: (Reader r :+: sig) (ReaderC r m) a -> ReaderC r m a Source #

(Algebra sig m, Effect sig) => Algebra (State s :+: sig) (StateT s m) Source # 
Instance details

Defined in Control.Algebra

Methods

alg :: (State s :+: sig) (StateT s m) a -> StateT s m a Source #

(Algebra sig m, Effect sig) => Algebra (State s :+: sig) (StateT s m) Source # 
Instance details

Defined in Control.Algebra

Methods

alg :: (State s :+: sig) (StateT s m) a -> StateT s m a Source #

(Algebra sig m, Effect sig) => Algebra (State s :+: sig) (StateC s m) Source # 
Instance details

Defined in Control.Carrier.State.Strict

Methods

alg :: (State s :+: sig) (StateC s m) a -> StateC s m a Source #

(Algebra sig m, Effect sig) => Algebra (State s :+: sig) (StateC s m) Source # 
Instance details

Defined in Control.Carrier.State.Lazy

Methods

alg :: (State s :+: sig) (StateC s m) a -> StateC s m a Source #

(Algebra sig m, Effect sig) => Algebra (Throw e :+: sig) (ThrowC e m) Source # 
Instance details

Defined in Control.Carrier.Throw.Either

Methods

alg :: (Throw e :+: sig) (ThrowC e m) a -> ThrowC e m a Source #

(Algebra sig m, Effect sig) => Algebra (Error e :+: sig) (ExceptT e m) Source # 
Instance details

Defined in Control.Algebra

Methods

alg :: (Error e :+: sig) (ExceptT e m) a -> ExceptT e m a Source #

(Algebra sig m, Effect sig) => Algebra (Error e :+: sig) (ErrorC e m) Source # 
Instance details

Defined in Control.Carrier.Error.Either

Methods

alg :: (Error e :+: sig) (ErrorC e m) a -> ErrorC e m a Source #

(Algebra sig m, Effect sig, Monoid w) => Algebra (Writer w :+: sig) (WriterT w m) Source # 
Instance details

Defined in Control.Algebra

Methods

alg :: (Writer w :+: sig) (WriterT w m) a -> WriterT w m a Source #

(Algebra sig m, Effect sig, Monoid w) => Algebra (Writer w :+: sig) (WriterT w m) Source # 
Instance details

Defined in Control.Algebra

Methods

alg :: (Writer w :+: sig) (WriterT w m) a -> WriterT w m a Source #

(Monoid w, Algebra sig m, Effect sig) => Algebra (Writer w :+: sig) (WriterC w m) Source # 
Instance details

Defined in Control.Carrier.Writer.Strict

Methods

alg :: (Writer w :+: sig) (WriterC w m) a -> WriterC w m a Source #

(HFunctor eff, HFunctor sig, Reifies s (Handler eff m), Monad m, Algebra sig m) => Algebra (eff :+: sig) (InterpretC s eff m) Source # 
Instance details

Defined in Control.Carrier.Interpret

Methods

alg :: (eff :+: sig) (InterpretC s eff m) a -> InterpretC s eff m a Source #

(Algebra sig m, Effect sig, Monoid w) => Algebra (Reader r :+: (Writer w :+: (State s :+: sig))) (RWST r w s m) Source # 
Instance details

Defined in Control.Algebra

Methods

alg :: (Reader r :+: (Writer w :+: (State s :+: sig))) (RWST r w s m) a -> RWST r w s m a Source #

(Algebra sig m, Effect sig, Monoid w) => Algebra (Reader r :+: (Writer w :+: (State s :+: sig))) (RWST r w s m) Source # 
Instance details

Defined in Control.Algebra

Methods

alg :: (Reader r :+: (Writer w :+: (State s :+: sig))) (RWST r w s m) a -> RWST r w s m a Source #

run :: Identity a -> a Source #

Run an action exhausted of effects to produce its final result value.

Since: 1.0.0.0

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:

  1. Due to a problem with recursive type families, this can lead to significantly slower compiles.
  2. It defeats ghc’s warnings for redundant constraints, and thus can lead to a proliferation of redundant constraints as code is changed.

send :: (Member eff sig, Algebra sig m) => eff m a -> m a Source #

Construct a request for an effect to be interpreted by some handler later on.

Re-exports

data (f :+: g) (m :: * -> *) k infixr 4 Source #

Higher-order sums are used to combine multiple effects into a signature, typically by chaining on the right.

Constructors

L (f m k) 
R (g m k) 
Instances
Algebra NonDet [] Source # 
Instance details

Defined in Control.Algebra

Methods

alg :: NonDet [] a -> [a] Source #

Member l r => Member l (l' :+: r) Source #

Right-recursion: if t is a member of r, we can inject it into r in O(n), followed by lifting that into l :+: r in O(1).

Instance details

Defined in Control.Effect.Sum

Methods

inj :: l m a -> (l' :+: r) m a Source #

Member l (l :+: r) Source #

Left-occurrence: if t is at the head of a signature, we can inject it in O(1).

Instance details

Defined in Control.Effect.Sum

Methods

inj :: l m a -> (l :+: r) m a Source #

Member t (l1 :+: (l2 :+: r)) => Member t ((l1 :+: l2) :+: r) Source #

Left-recursion: if t is a member of l1 :+: l2 :+: r, then we can inject it into (l1 :+: l2) :+: r by injection into a right-recursive signature, followed by left-association.

Instance details

Defined in Control.Effect.Sum

Methods

inj :: t m a -> ((l1 :+: l2) :+: r) m a Source #

Algebra (Error e) (Either e) Source # 
Instance details

Defined in Control.Algebra

Methods

alg :: Error e (Either e) a -> Either e a Source #

Generic1 ((f :+: g) m :: Type -> Type) Source # 
Instance details

Defined in Control.Effect.Sum

Associated Types

type Rep1 ((f :+: g) m) :: k -> Type #

Methods

from1 :: (f :+: g) m a -> Rep1 ((f :+: g) m) a #

to1 :: Rep1 ((f :+: g) m) a -> (f :+: g) m a #

(Effect f, Effect g) => Effect (f :+: g) Source # 
Instance details

Defined in Control.Effect.Sum

Methods

thread :: (Functor ctx, Monad m) => ctx () -> (forall x. ctx (m x) -> n (ctx x)) -> (f :+: g) m a -> (f :+: g) n (ctx a) Source #

(HFunctor f, HFunctor g) => HFunctor (f :+: g) Source # 
Instance details

Defined in Control.Effect.Sum

Methods

hmap :: Functor m => (forall x. m x -> n x) -> (f :+: g) m a -> (f :+: g) n a Source #

(Algebra sig m, Effect sig) => Algebra (Choose :+: sig) (ChooseC m) Source # 
Instance details

Defined in Control.Carrier.Choose.Church

Methods

alg :: (Choose :+: sig) (ChooseC m) a -> ChooseC m a Source #

(Algebra sig m, Effect sig) => Algebra (Empty :+: sig) (EmptyC m) Source # 
Instance details

Defined in Control.Carrier.Empty.Maybe

Methods

alg :: (Empty :+: sig) (EmptyC m) a -> EmptyC m a Source #

(Algebra sig m, Effect sig) => Algebra (NonDet :+: sig) (NonDetC m) Source # 
Instance details

Defined in Control.Carrier.NonDet.Church

Methods

alg :: (NonDet :+: sig) (NonDetC m) a -> NonDetC m a Source #

(MonadIO m, Algebra sig m) => Algebra (Trace :+: sig) (TraceC m) Source # 
Instance details

Defined in Control.Carrier.Trace.Printing

Methods

alg :: (Trace :+: sig) (TraceC m) a -> TraceC m a Source #

Algebra sig m => Algebra (Trace :+: sig) (TraceC m) Source # 
Instance details

Defined in Control.Carrier.Trace.Ignoring

Methods

alg :: (Trace :+: sig) (TraceC m) a -> TraceC m a Source #

(Algebra sig m, Effect sig) => Algebra (Trace :+: sig) (TraceC m) Source # 
Instance details

Defined in Control.Carrier.Trace.Returning

Methods

alg :: (Trace :+: sig) (TraceC m) a -> TraceC m a Source #

(Algebra sig m, Effect sig) => Algebra (Fail :+: sig) (FailC m) Source # 
Instance details

Defined in Control.Carrier.Fail.Either

Methods

alg :: (Fail :+: sig) (FailC m) a -> FailC m a Source #

(Algebra sig m, Effect sig) => Algebra (Fresh :+: sig) (FreshC m) Source # 
Instance details

Defined in Control.Carrier.Fresh.Strict

Methods

alg :: (Fresh :+: sig) (FreshC m) a -> FreshC m a Source #

(Algebra sig m, Effect sig) => Algebra (Cut :+: (NonDet :+: sig)) (CutC m) Source # 
Instance details

Defined in Control.Carrier.Cut.Church

Methods

alg :: (Cut :+: (NonDet :+: sig)) (CutC m) a -> CutC m a Source #

(Algebra sig m, Effect sig) => Algebra (Cull :+: (NonDet :+: sig)) (CullC m) Source # 
Instance details

Defined in Control.Carrier.Cull.Church

Methods

alg :: (Cull :+: (NonDet :+: sig)) (CullC m) a -> CullC m a Source #

Algebra sig m => Algebra (Reader r :+: sig) (ReaderT r m) Source # 
Instance details

Defined in Control.Algebra

Methods

alg :: (Reader r :+: sig) (ReaderT r m) a -> ReaderT r m a Source #

Algebra sig m => Algebra (Reader r :+: sig) (ReaderC r m) Source # 
Instance details

Defined in Control.Carrier.Reader

Methods

alg :: (Reader r :+: sig) (ReaderC r m) a -> ReaderC r m a Source #

(Algebra sig m, Effect sig) => Algebra (State s :+: sig) (StateT s m) Source # 
Instance details

Defined in Control.Algebra

Methods

alg :: (State s :+: sig) (StateT s m) a -> StateT s m a Source #

(Algebra sig m, Effect sig) => Algebra (State s :+: sig) (StateT s m) Source # 
Instance details

Defined in Control.Algebra

Methods

alg :: (State s :+: sig) (StateT s m) a -> StateT s m a Source #

(Algebra sig m, Effect sig) => Algebra (State s :+: sig) (StateC s m) Source # 
Instance details

Defined in Control.Carrier.State.Strict

Methods

alg :: (State s :+: sig) (StateC s m) a -> StateC s m a Source #

(Algebra sig m, Effect sig) => Algebra (State s :+: sig) (StateC s m) Source # 
Instance details

Defined in Control.Carrier.State.Lazy

Methods

alg :: (State s :+: sig) (StateC s m) a -> StateC s m a Source #

(Algebra sig m, Effect sig) => Algebra (Throw e :+: sig) (ThrowC e m) Source # 
Instance details

Defined in Control.Carrier.Throw.Either

Methods

alg :: (Throw e :+: sig) (ThrowC e m) a -> ThrowC e m a Source #

(Algebra sig m, Effect sig) => Algebra (Error e :+: sig) (ExceptT e m) Source # 
Instance details

Defined in Control.Algebra

Methods

alg :: (Error e :+: sig) (ExceptT e m) a -> ExceptT e m a Source #

(Algebra sig m, Effect sig) => Algebra (Error e :+: sig) (ErrorC e m) Source # 
Instance details

Defined in Control.Carrier.Error.Either

Methods

alg :: (Error e :+: sig) (ErrorC e m) a -> ErrorC e m a Source #

(Algebra sig m, Effect sig, Monoid w) => Algebra (Writer w :+: sig) (WriterT w m) Source # 
Instance details

Defined in Control.Algebra

Methods

alg :: (Writer w :+: sig) (WriterT w m) a -> WriterT w m a Source #

(Algebra sig m, Effect sig, Monoid w) => Algebra (Writer w :+: sig) (WriterT w m) Source # 
Instance details

Defined in Control.Algebra

Methods

alg :: (Writer w :+: sig) (WriterT w m) a -> WriterT w m a Source #

(Monoid w, Algebra sig m, Effect sig) => Algebra (Writer w :+: sig) (WriterC w m) Source # 
Instance details

Defined in Control.Carrier.Writer.Strict

Methods

alg :: (Writer w :+: sig) (WriterC w m) a -> WriterC w m a Source #

(HFunctor eff, HFunctor sig, Reifies s (Handler eff m), Monad m, Algebra sig m) => Algebra (eff :+: sig) (InterpretC s eff m) Source # 
Instance details

Defined in Control.Carrier.Interpret

Methods

alg :: (eff :+: sig) (InterpretC s eff m) a -> InterpretC s eff m a Source #

(Algebra sig m, Effect sig, Monoid w) => Algebra (Reader r :+: (Writer w :+: (State s :+: sig))) (RWST r w s m) Source # 
Instance details

Defined in Control.Algebra

Methods

alg :: (Reader r :+: (Writer w :+: (State s :+: sig))) (RWST r w s m) a -> RWST r w s m a Source #

(Algebra sig m, Effect sig, Monoid w) => Algebra (Reader r :+: (Writer w :+: (State s :+: sig))) (RWST r w s m) Source # 
Instance details

Defined in Control.Algebra

Methods

alg :: (Reader r :+: (Writer w :+: (State s :+: sig))) (RWST r w s m) a -> RWST r w s m a Source #

(Functor (f m), Functor (g m)) => Functor ((f :+: g) m) Source # 
Instance details

Defined in Control.Effect.Sum

Methods

fmap :: (a -> b) -> (f :+: g) m a -> (f :+: g) m b #

(<$) :: a -> (f :+: g) m b -> (f :+: g) m a #

(Foldable (f m), Foldable (g m)) => Foldable ((f :+: g) m) Source # 
Instance details

Defined in Control.Effect.Sum

Methods

fold :: Monoid m0 => (f :+: g) m m0 -> m0 #

foldMap :: Monoid m0 => (a -> m0) -> (f :+: g) m a -> m0 #

foldr :: (a -> b -> b) -> b -> (f :+: g) m a -> b #

foldr' :: (a -> b -> b) -> b -> (f :+: g) m a -> b #

foldl :: (b -> a -> b) -> b -> (f :+: g) m a -> b #

foldl' :: (b -> a -> b) -> b -> (f :+: g) m a -> b #

foldr1 :: (a -> a -> a) -> (f :+: g) m a -> a #

foldl1 :: (a -> a -> a) -> (f :+: g) m a -> a #

toList :: (f :+: g) m a -> [a] #

null :: (f :+: g) m a -> Bool #

length :: (f :+: g) m a -> Int #

elem :: Eq a => a -> (f :+: g) m a -> Bool #

maximum :: Ord a => (f :+: g) m a -> a #

minimum :: Ord a => (f :+: g) m a -> a #

sum :: Num a => (f :+: g) m a -> a #

product :: Num a => (f :+: g) m a -> a #

(Traversable (f m), Traversable (g m)) => Traversable ((f :+: g) m) Source # 
Instance details

Defined in Control.Effect.Sum

Methods

traverse :: Applicative f0 => (a -> f0 b) -> (f :+: g) m a -> f0 ((f :+: g) m b) #

sequenceA :: Applicative f0 => (f :+: g) m (f0 a) -> f0 ((f :+: g) m a) #

mapM :: Monad m0 => (a -> m0 b) -> (f :+: g) m a -> m0 ((f :+: g) m b) #

sequence :: Monad m0 => (f :+: g) m (m0 a) -> m0 ((f :+: g) m a) #

(Eq (f m k), Eq (g m k)) => Eq ((f :+: g) m k) Source # 
Instance details

Defined in Control.Effect.Sum

Methods

(==) :: (f :+: g) m k -> (f :+: g) m k -> Bool #

(/=) :: (f :+: g) m k -> (f :+: g) m k -> Bool #

(Ord (f m k), Ord (g m k)) => Ord ((f :+: g) m k) Source # 
Instance details

Defined in Control.Effect.Sum

Methods

compare :: (f :+: g) m k -> (f :+: g) m k -> Ordering #

(<) :: (f :+: g) m k -> (f :+: g) m k -> Bool #

(<=) :: (f :+: g) m k -> (f :+: g) m k -> Bool #

(>) :: (f :+: g) m k -> (f :+: g) m k -> Bool #

(>=) :: (f :+: g) m k -> (f :+: g) m k -> Bool #

max :: (f :+: g) m k -> (f :+: g) m k -> (f :+: g) m k #

min :: (f :+: g) m k -> (f :+: g) m k -> (f :+: g) m k #

(Show (f m k), Show (g m k)) => Show ((f :+: g) m k) Source # 
Instance details

Defined in Control.Effect.Sum

Methods

showsPrec :: Int -> (f :+: g) m k -> ShowS #

show :: (f :+: g) m k -> String #

showList :: [(f :+: g) m k] -> ShowS #

type Rep1 ((f :+: g) m :: Type -> Type) Source # 
Instance details

Defined in Control.Effect.Sum

type Rep1 ((f :+: g) m :: Type -> Type) = D1 (MetaData ":+:" "Control.Effect.Sum" "fused-effects-1.0.0.0-inplace" False) (C1 (MetaCons "L" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec1 (f m))) :+: C1 (MetaCons "R" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec1 (g m))))