fused-effects-0.5.0.1: A fast, flexible, fused effect system.
Safe HaskellNone
LanguageHaskell2010

Control.Effect.Resumable

Synopsis

Resumable effect

data Resumable err m k Source #

Errors which can be resumed with values of some existentially-quantified type.

Constructors

forall a. Resumable (err a) (a -> m k) 

Instances

Instances details
Effect (Resumable err) Source # 
Instance details

Defined in Control.Effect.Resumable

Methods

handle :: (Functor f, Monad m) => f () -> (forall x. f (m x) -> n (f x)) -> Resumable err m a -> Resumable err n (f a) Source #

HFunctor (Resumable err) Source # 
Instance details

Defined in Control.Effect.Resumable

Methods

fmap' :: forall (f :: Type -> Type) a b. Functor (Resumable err f) => (a -> b) -> Resumable err f a -> Resumable err f b Source #

hmap :: Functor m => (forall x. m x -> n x) -> Resumable err m a -> Resumable err n a Source #

Functor m => Functor (Resumable err m) Source # 
Instance details

Defined in Control.Effect.Resumable

Methods

fmap :: (a -> b) -> Resumable err m a -> Resumable err m b #

(<$) :: a -> Resumable err m b -> Resumable err m a #

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

Defined in Control.Effect.Resumable

Methods

eff :: (Resumable err :+: sig) (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

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

throwResumable :: (Member (Resumable err) sig, Carrier sig m) => err a -> m a Source #

Throw an error which can be resumed with a value of its result type.

run (runResumable (throwResumable (Identity a))) === Left (SomeError (Identity a))

data SomeError err Source #

An error at some existentially-quantified type index.

Constructors

forall a. SomeError (err a) 

Instances

Instances details
Eq1 err => Eq (SomeError err) Source #

Equality for SomeError is determined by an Eq1 instance for the error type.

Note that since we can’t tell whether the type indices are equal, let alone what Eq instance to use for them, the comparator passed to liftEq always returns True. Thus, SomeError is best used with type-indexed GADTs for the error type.

SomeError (Identity a) === SomeError (Identity b)
(SomeError (Const a) === SomeError (Const b)) == (a == b)
Instance details

Defined in Control.Effect.Resumable

Methods

(==) :: SomeError err -> SomeError err -> Bool #

(/=) :: SomeError err -> SomeError err -> Bool #

Ord1 err => Ord (SomeError err) Source #

Ordering for SomeError is determined by an Ord1 instance for the error type.

Note that since we can’t tell whether the type indices are equal, let alone what Ord instance to use for them, the comparator passed to liftCompare always returns EQ. Thus, SomeError is best used with type-indexed GADTs for the error type.

(SomeError (Identity a) `compare` SomeError (Identity b)) === EQ
(SomeError (Const a) `compare` SomeError (Const b)) === (a `compare` b)
Instance details

Defined in Control.Effect.Resumable

Methods

compare :: SomeError err -> SomeError err -> Ordering #

(<) :: SomeError err -> SomeError err -> Bool #

(<=) :: SomeError err -> SomeError err -> Bool #

(>) :: SomeError err -> SomeError err -> Bool #

(>=) :: SomeError err -> SomeError err -> Bool #

max :: SomeError err -> SomeError err -> SomeError err #

min :: SomeError err -> SomeError err -> SomeError err #

Show1 err => Show (SomeError err) Source #

Showing for SomeError is determined by a Show1 instance for the error type.

Note that since we can’t tell what Show instance to use for the type index, the functions passed to liftShowsPrec always return the empty ShowS. Thus, SomeError is best used with type-indexed GADTs for the error type.

show (SomeError (Identity a)) === "SomeError (Identity )"
show (SomeError (Const a)) === ("SomeError (Const " ++ showsPrec 11 a ")")
Instance details

Defined in Control.Effect.Resumable

Methods

showsPrec :: Int -> SomeError err -> ShowS #

show :: SomeError err -> String #

showList :: [SomeError err] -> ShowS #

NFData1 err => NFData (SomeError err) Source #

Evaluation of SomeError to normal forms is determined by a NFData1 instance for the error type.

pure (rnf (SomeError (Identity (error "error"))) :: SomeError Identity) `shouldThrow` errorCall "error"
Instance details

Defined in Control.Effect.Resumable

Methods

rnf :: SomeError err -> () #

Resumable carriers

runResumable :: ResumableC err m a -> m (Either (SomeError err) a) Source #

Run a Resumable effect, returning uncaught errors in Left and successful computations’ values in Right.

run (runResumable (pure a)) === Right @(SomeError Identity) @Int a

newtype ResumableC err m a Source #

Constructors

ResumableC 

Fields

Instances

Instances details
MonadTrans (ResumableC err) Source # 
Instance details

Defined in Control.Effect.Resumable

Methods

lift :: Monad m => m a -> ResumableC err m a #

Monad m => Monad (ResumableC err m) Source # 
Instance details

Defined in Control.Effect.Resumable

Methods

(>>=) :: ResumableC err m a -> (a -> ResumableC err m b) -> ResumableC err m b #

(>>) :: ResumableC err m a -> ResumableC err m b -> ResumableC err m b #

return :: a -> ResumableC err m a #

Functor m => Functor (ResumableC err m) Source # 
Instance details

Defined in Control.Effect.Resumable

Methods

fmap :: (a -> b) -> ResumableC err m a -> ResumableC err m b #

(<$) :: a -> ResumableC err m b -> ResumableC err m a #

MonadFix m => MonadFix (ResumableC err m) Source # 
Instance details

Defined in Control.Effect.Resumable

Methods

mfix :: (a -> ResumableC err m a) -> ResumableC err m a #

MonadFail m => MonadFail (ResumableC err m) Source # 
Instance details

Defined in Control.Effect.Resumable

Methods

fail :: String -> ResumableC err m a #

Applicative m => Applicative (ResumableC err m) Source # 
Instance details

Defined in Control.Effect.Resumable

Methods

pure :: a -> ResumableC err m a #

(<*>) :: ResumableC err m (a -> b) -> ResumableC err m a -> ResumableC err m b #

liftA2 :: (a -> b -> c) -> ResumableC err m a -> ResumableC err m b -> ResumableC err m c #

(*>) :: ResumableC err m a -> ResumableC err m b -> ResumableC err m b #

(<*) :: ResumableC err m a -> ResumableC err m b -> ResumableC err m a #

MonadIO m => MonadIO (ResumableC err m) Source # 
Instance details

Defined in Control.Effect.Resumable

Methods

liftIO :: IO a -> ResumableC err m a #

Alternative m => Alternative (ResumableC err m) Source # 
Instance details

Defined in Control.Effect.Resumable

Methods

empty :: ResumableC err m a #

(<|>) :: ResumableC err m a -> ResumableC err m a -> ResumableC err m a #

some :: ResumableC err m a -> ResumableC err m [a] #

many :: ResumableC err m a -> ResumableC err m [a] #

(Alternative m, Monad m) => MonadPlus (ResumableC err m) Source # 
Instance details

Defined in Control.Effect.Resumable

Methods

mzero :: ResumableC err m a #

mplus :: ResumableC err m a -> ResumableC err m a -> ResumableC err m a #

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

Defined in Control.Effect.Resumable

Methods

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

runResumableWith :: (forall x. err x -> m x) -> ResumableWithC err m a -> m a Source #

Run a Resumable effect, resuming uncaught errors with a given handler.

Note that this may be less efficient than defining a specialized carrier type and instance specifying the handler’s behaviour directly. Performance-critical code may wish to do that to maximize the opportunities for fusion and inlining.

>>> data Err a where Err :: Int -> Err Int
run (runResumableWith (\ (Err b) -> pure (1 + b)) (pure a)) === a
run (runResumableWith (\ (Err b) -> pure (1 + b)) (throwResumable (Err a))) === 1 + a

newtype ResumableWithC err m a Source #

Constructors

ResumableWithC 

Fields

Instances

Instances details
MonadTrans (ResumableWithC err) Source # 
Instance details

Defined in Control.Effect.Resumable

Methods

lift :: Monad m => m a -> ResumableWithC err m a #

Monad m => Monad (ResumableWithC err m) Source # 
Instance details

Defined in Control.Effect.Resumable

Methods

(>>=) :: ResumableWithC err m a -> (a -> ResumableWithC err m b) -> ResumableWithC err m b #

(>>) :: ResumableWithC err m a -> ResumableWithC err m b -> ResumableWithC err m b #

return :: a -> ResumableWithC err m a #

Functor m => Functor (ResumableWithC err m) Source # 
Instance details

Defined in Control.Effect.Resumable

Methods

fmap :: (a -> b) -> ResumableWithC err m a -> ResumableWithC err m b #

(<$) :: a -> ResumableWithC err m b -> ResumableWithC err m a #

MonadFix m => MonadFix (ResumableWithC err m) Source # 
Instance details

Defined in Control.Effect.Resumable

Methods

mfix :: (a -> ResumableWithC err m a) -> ResumableWithC err m a #

MonadFail m => MonadFail (ResumableWithC err m) Source # 
Instance details

Defined in Control.Effect.Resumable

Methods

fail :: String -> ResumableWithC err m a #

Applicative m => Applicative (ResumableWithC err m) Source # 
Instance details

Defined in Control.Effect.Resumable

Methods

pure :: a -> ResumableWithC err m a #

(<*>) :: ResumableWithC err m (a -> b) -> ResumableWithC err m a -> ResumableWithC err m b #

liftA2 :: (a -> b -> c) -> ResumableWithC err m a -> ResumableWithC err m b -> ResumableWithC err m c #

(*>) :: ResumableWithC err m a -> ResumableWithC err m b -> ResumableWithC err m b #

(<*) :: ResumableWithC err m a -> ResumableWithC err m b -> ResumableWithC err m a #

MonadIO m => MonadIO (ResumableWithC err m) Source # 
Instance details

Defined in Control.Effect.Resumable

Methods

liftIO :: IO a -> ResumableWithC err m a #

Alternative m => Alternative (ResumableWithC err m) Source # 
Instance details

Defined in Control.Effect.Resumable

Methods

empty :: ResumableWithC err m a #

(<|>) :: ResumableWithC err m a -> ResumableWithC err m a -> ResumableWithC err m a #

some :: ResumableWithC err m a -> ResumableWithC err m [a] #

many :: ResumableWithC err m a -> ResumableWithC err m [a] #

(Alternative m, Monad m) => MonadPlus (ResumableWithC err m) Source # 
Instance details

Defined in Control.Effect.Resumable

Methods

mzero :: ResumableWithC err m a #

mplus :: ResumableWithC err m a -> ResumableWithC err m a -> ResumableWithC err m a #

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

Defined in Control.Effect.Resumable

Methods

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

Re-exports

class (HFunctor sig, Monad m) => Carrier sig m | m -> sig Source #

The class of carriers (results) for algebras (effect handlers) over signatures (effects), whose actions are given by the eff method.

Minimal complete definition

eff

Instances

Instances details
Carrier Pure PureC Source # 
Instance details

Defined in Control.Effect.Carrier

Methods

eff :: Pure PureC a -> PureC a Source #

(HFunctor eff, Carrier sig m, Member eff sig) => Carrier sig (InterposeC eff m) Source # 
Instance details

Defined in Control.Effect.Interpose

Methods

eff :: sig (InterposeC eff m) a -> InterposeC eff m a Source #

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

Defined in Control.Effect.Lift

Methods

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

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

Defined in Control.Effect.Resource

Methods

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

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

Defined in Control.Effect.NonDet

Methods

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

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

Defined in Control.Effect.Cull

Methods

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

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

Defined in Control.Effect.Fresh

Methods

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

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

Defined in Control.Effect.Fail

Methods

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

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

Defined in Control.Effect.Cut

Methods

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

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

Defined in Control.Effect.Cull

Methods

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

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

Defined in Control.Effect.Trace

Methods

eff :: (Trace :+: sig) (TraceByReturningC m) a -> TraceByReturningC m a Source #

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

Defined in Control.Effect.Trace

Methods

eff :: (Trace :+: sig) (TraceByIgnoringC m) a -> TraceByIgnoringC m a Source #

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

Defined in Control.Effect.Trace

Methods

eff :: (Trace :+: sig) (TraceByPrintingC m) a -> TraceByPrintingC m a Source #

(HFunctor eff, Carrier sig m) => Carrier (eff :+: sig) (InterpretC eff m) Source # 
Instance details

Defined in Control.Effect.Interpret

Methods

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

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

Defined in Control.Effect.State.Strict

Methods

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

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

Defined in Control.Effect.State.Lazy

Methods

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

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

Defined in Control.Effect.Reader

Methods

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

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

Defined in Control.Effect.Random

Methods

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

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

Defined in Control.Effect.Error

Methods

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

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

Defined in Control.Effect.Resumable

Methods

eff :: (Resumable err :+: sig) (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

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

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

Defined in Control.Effect.Writer

Methods

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

(HFunctor eff, Carrier sig m, Effect sig) => Carrier (eff :+: sig) (InterpretStateC eff s m) Source # 
Instance details

Defined in Control.Effect.Interpret

Methods

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

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

Minimal complete definition

inj, prj

Instances

Instances details
Member sub sub Source # 
Instance details

Defined in Control.Effect.Sum

Methods

inj :: forall (m :: Type -> Type) a. sub m a -> sub m a Source #

prj :: forall (m :: Type -> Type) a. 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 :: forall (m :: Type -> Type) a. sub m a -> (sub' :+: sup) m a Source #

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

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

Defined in Control.Effect.Sum

Methods

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

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

run :: PureC a -> a Source #

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