Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Resumable err m k = Resumable (err a) (a -> m k)
- throwResumable :: (Member (Resumable err) sig, Carrier sig m) => err a -> m a
- data SomeError err = SomeError (err a)
- runResumable :: ResumableC err m a -> m (Either (SomeError err) a)
- newtype ResumableC err m a = ResumableC {
- runResumableC :: ErrorC (SomeError err) m a
- runResumableWith :: (forall x. err x -> m x) -> ResumableWithC err m a -> m a
- newtype ResumableWithC err m a = ResumableWithC {
- runResumableWithC :: ReaderC (Handler err m) m a
- class (HFunctor sig, Monad m) => Carrier sig m | m -> sig
- class Member (sub :: (* -> *) -> * -> *) sup
- run :: PureC a -> a
Resumable effect
data Resumable err m k Source #
Errors which can be resumed with values of some existentially-quantified type.
Resumable (err a) (a -> m k) |
Instances
Effect (Resumable err) Source # | |
HFunctor (Resumable err) Source # | |
Functor m => Functor (Resumable err m) Source # | |
Carrier sig m => Carrier (Resumable err :+: sig) (ResumableWithC err m) Source # | |
Defined in Control.Effect.Resumable 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 # | |
Defined in Control.Effect.Resumable 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))
An error at some existentially-quantified type index.
SomeError (err a) |
Instances
Eq1 err => Eq (SomeError err) Source # | Equality for Note that since we can’t tell whether the type indices are equal, let alone what SomeError (Identity a) === SomeError (Identity b) (SomeError (Const a) === SomeError (Const b)) == (a == b) |
Ord1 err => Ord (SomeError err) Source # | Ordering for Note that since we can’t tell whether the type indices are equal, let alone what (SomeError (Identity a) `compare` SomeError (Identity b)) === EQ (SomeError (Const a) `compare` SomeError (Const b)) === (a `compare` b) |
Defined in Control.Effect.Resumable 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 # | |
Show1 err => Show (SomeError err) Source # | Showing for Note that since we can’t tell what show (SomeError (Identity a)) === "SomeError (Identity )" show (SomeError (Const a)) === ("SomeError (Const " ++ showsPrec 11 a ")") |
NFData1 err => NFData (SomeError err) Source # | Evaluation of pure (rnf (SomeError (Identity (error "error"))) :: SomeError Identity) `shouldThrow` errorCall "error" |
Defined in Control.Effect.Resumable |
Resumable carriers
runResumable :: ResumableC err m a -> m (Either (SomeError err) a) Source #
newtype ResumableC err m a Source #
ResumableC | |
|
Instances
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 #
ResumableWithC | |
|
Instances
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.