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

Safe HaskellNone
LanguageHaskell2010

Control.Effect.Sum

Synopsis
  • data (f :+: g) (m :: * -> *) k
    • = L (f m k)
    • | R (g m k)
  • handleSum :: (sig2 m a -> b) -> (sig1 m a -> b) -> (sig1 :+: sig2) m a -> b
  • class Member (sub :: (* -> *) -> * -> *) sup where
    • inj :: sub m a -> sup m a
    • prj :: sup m a -> Maybe (sub m a)
  • send :: (Member effect sig, Carrier sig m) => effect m (m a) -> m a

Documentation

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

Constructors

L (f m k) 
R (g m k) 
Instances
Member sub sup => Member sub (sub' :+: sup) Source # 
Instance details

Defined in Control.Effect.Sum

Methods

inj :: sub m a -> (sub' :+: sup) m a Source #

prj :: (sub' :+: sup) m a -> Maybe (sub m a) Source #

Member sub (sub :+: sup) Source # 
Instance details

Defined in Control.Effect.Sum

Methods

inj :: sub m a -> (sub :+: sup) m a Source #

prj :: (sub :+: sup) m a -> Maybe (sub m a) Source #

(Effect l, Effect r) => Effect (l :+: r) Source # 
Instance details

Defined in Control.Effect.Sum

Methods

handle :: Functor f => f () -> (forall x. f (m x) -> n (f x)) -> (l :+: r) m (m a) -> (l :+: r) n (n (f a)) Source #

(HFunctor l, HFunctor r) => HFunctor (l :+: r) Source # 
Instance details

Defined in Control.Effect.Sum

Methods

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

hmap :: (forall x. m x -> n x) -> (l :+: r) m a -> (l :+: r) n a Source #

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

Defined in Control.Effect.Fail

Methods

ret :: a -> FailC m a Source #

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

(Carrier sig m, MonadIO m) => Carrier (Resource :+: sig) (ResourceC m) Source # 
Instance details

Defined in Control.Effect.Resource

Methods

ret :: a -> ResourceC m a Source #

eff :: (Resource :+: sig) (ResourceC m) (ResourceC m a) -> ResourceC m a Source #

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

Defined in Control.Effect.Fresh

Methods

ret :: a -> FreshC m a Source #

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

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

Defined in Control.Effect.Cull

Methods

ret :: a -> CullC m a Source #

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

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

Defined in Control.Effect.Cut

Methods

ret :: a -> CutC m a Source #

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

(Carrier sig m, Effect sig) => Carrier (Trace :+: sig) (TraceByReturningC m) Source # 
Instance details

Defined in Control.Effect.Trace

Carrier sig m => Carrier (Trace :+: sig) (TraceByIgnoringC m) Source # 
Instance details

Defined in Control.Effect.Trace

(MonadIO m, Carrier sig m) => Carrier (Trace :+: sig) (TraceByPrintingC m) Source # 
Instance details

Defined in Control.Effect.Trace

(Alternative f, Carrier sig m, Effect sig, Traversable f, Monad f, Monad m) => Carrier (NonDet :+: sig) (OnceC f m) Source # 
Instance details

Defined in Control.Effect.NonDet

Methods

ret :: a -> OnceC f m a Source #

eff :: (NonDet :+: sig) (OnceC f m) (OnceC f m a) -> OnceC f m a Source #

(Alternative f, Monad f, Traversable f, Carrier sig m, Effect sig, Applicative m) => Carrier (NonDet :+: sig) (AltC f m) Source # 
Instance details

Defined in Control.Effect.NonDet

Methods

ret :: a -> AltC f m a Source #

eff :: (NonDet :+: sig) (AltC f m) (AltC f m a) -> AltC f m a Source #

(Carrier sig m, Effect sig, RandomGen g, Monad m) => Carrier (Random :+: sig) (RandomC g m) Source # 
Instance details

Defined in Control.Effect.Random

Methods

ret :: a -> RandomC g m a Source #

eff :: (Random :+: sig) (RandomC g m) (RandomC g m a) -> RandomC g m a Source #

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

Defined in Control.Effect.State

Methods

ret :: a -> StateC s m a Source #

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

(Carrier sig m, Monad m) => Carrier (Resumable err :+: sig) (ResumableWithC err m) Source # 
Instance details

Defined in Control.Effect.Resumable

Methods

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 # 
Instance details

Defined in Control.Effect.Resumable

Methods

ret :: a -> ResumableC err m a Source #

eff :: (Resumable err :+: sig) (ResumableC err m) (ResumableC err m a) -> ResumableC err m a Source #

(Carrier sig m, Monad m) => Carrier (Reader r :+: sig) (ReaderC r m) Source # 
Instance details

Defined in Control.Effect.Reader

Methods

ret :: a -> ReaderC r m a Source #

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

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

Defined in Control.Effect.Error

Methods

ret :: a -> ErrorC e m a Source #

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

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

Defined in Control.Effect.Writer

Methods

ret :: a -> WriterC w m a Source #

eff :: (Writer w :+: sig) (WriterC w m) (WriterC w m a) -> WriterC w 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 #

(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 #

handleSum :: (sig2 m a -> b) -> (sig1 m a -> b) -> (sig1 :+: sig2) m a -> b Source #

Lift algebras for either side of a sum into a single algebra on sums.

Note that the order of the functions is the opposite of members of the sum. This is more convenient for defining effect handlers as lambdas (especially using -XLambdaCase) on the right, enabling better error messaging when using typed holes than would be the case with a binding in a where clause.

class Member (sub :: (* -> *) -> * -> *) sup where Source #

Methods

inj :: sub m a -> sup m a Source #

prj :: sup m a -> Maybe (sub m a) Source #

Instances
Member sub sub Source # 
Instance details

Defined in Control.Effect.Sum

Methods

inj :: sub m a -> sub m a Source #

prj :: sub m a -> Maybe (sub m a) Source #

Member sub sup => Member sub (sub' :+: sup) Source # 
Instance details

Defined in Control.Effect.Sum

Methods

inj :: sub m a -> (sub' :+: sup) m a Source #

prj :: (sub' :+: sup) m a -> Maybe (sub m a) Source #

Member sub (sub :+: sup) Source # 
Instance details

Defined in Control.Effect.Sum

Methods

inj :: sub m a -> (sub :+: sup) m a Source #

prj :: (sub :+: sup) m a -> Maybe (sub m a) Source #

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.