Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- resume :: forall err eff r a. Member (Resumable err eff) r => Sem (eff ': r) a -> (err -> Sem r a) -> Sem r a
- (!!) :: forall err eff r a. Member (Resumable err eff) r => Sem (eff ': r) a -> (err -> Sem r a) -> Sem r a
- resumeRe :: forall err eff r a. Sem (eff ': r) a -> (err -> Sem (Resumable err eff ': r) a) -> Sem (Resumable err eff ': r) a
- resuming :: forall err eff r a. Member (Resumable err eff) r => (err -> Sem r a) -> Sem (eff ': r) a -> Sem r a
- resumingRe :: forall err eff r a. (err -> Sem (Resumable err eff ': r) a) -> Sem (eff ': r) a -> Sem (Resumable err eff ': r) a
- resumeAs :: forall err eff r a. Member (Resumable err eff) r => a -> Sem (eff ': r) a -> Sem r a
- (<!) :: forall err eff r a. Member (Resumable err eff) r => a -> Sem (eff ': r) a -> Sem r a
- (!>) :: forall err eff r a. Member (Resumable err eff) r => Sem (eff ': r) a -> a -> Sem r a
- resume_ :: forall err eff r. Member (Resumable err eff) r => Sem (eff ': r) () -> Sem r ()
- resumeWith :: forall err eff r a. Member (Resumable err eff) r => Sem (eff ': r) a -> Sem r a -> Sem r a
- (!>>) :: forall err eff r a. Member (Resumable err eff) r => Sem (eff ': r) a -> Sem r a -> Sem r a
- resumingWith :: forall err eff r a. Member (Resumable err eff) r => Sem r a -> Sem (eff ': r) a -> Sem r a
- (<<!) :: forall err eff r a. Member (Resumable err eff) r => Sem r a -> Sem (eff ': r) a -> Sem r a
- resumeHoist :: forall err eff err' r a. Members [Resumable err eff, Stop err'] r => (err -> err') -> Sem (eff ': r) a -> Sem r a
- resumeHoistAs :: forall err eff err' r. Members [Resumable err eff, Stop err'] r => err' -> InterpreterFor eff r
- restop :: forall err eff r. Members [Resumable err eff, Stop err] r => InterpreterFor eff r
- resumeEither :: forall err eff r a. Member (Resumable err eff) r => Sem (eff ': r) a -> Sem r (Either err a)
- resumeOr :: forall err eff r a b. Member (Resumable err eff) r => Sem (eff ': r) a -> (a -> Sem r b) -> (err -> Sem r b) -> Sem r b
- resumingOr :: forall err eff r a b. Member (Resumable err eff) r => (err -> Sem r b) -> Sem (eff ': r) a -> (a -> Sem r b) -> Sem r b
- resumeHoistError :: forall err eff err' r a. Members [Resumable err eff, Error err'] r => (err -> err') -> Sem (eff ': r) a -> Sem r a
- resumeHoistErrorAs :: forall err eff err' r a. Members [Resumable err eff, Error err'] r => err' -> Sem (eff ': r) a -> Sem r a
- resumeError :: forall err eff r a. Members [Resumable err eff, Error err] r => Sem (eff ': r) a -> Sem r a
Documentation
resume :: forall err eff r a. Member (Resumable err eff) r => Sem (eff ': r) a -> (err -> Sem r a) -> Sem r a Source #
Execute the action of a regular effect eff
so that any error of type err
that maybe be thrown by the (unknown)
interpreter used for eff
will be caught here and handled by the handler
argument.
This is similar to catch
with the additional guarantee that the error will have to be explicitly
matched, therefore preventing accidental failure to handle an error and bubbling it up to main
.
It also imposes a membership of Resumable err eff
on the program, requiring the interpreter for eff
to be adapted
with resumable
.
data Resumer :: Effect where MainProgram :: Resumer m Int makeSem ''Resumer interpretResumer :: Member (Resumable Boom Stopper) r => InterpreterFor Resumer r interpretResumer = interpret \ MainProgram -> resume (192 <$ stopBang) \ _ -> pure 237
(!!) :: forall err eff r a. Member (Resumable err eff) r => Sem (eff ': r) a -> (err -> Sem r a) -> Sem r a Source #
Operator version of resume
.
Since: 0.2.0.0
resumeRe :: forall err eff r a. Sem (eff ': r) a -> (err -> Sem (Resumable err eff ': r) a) -> Sem (Resumable err eff ': r) a Source #
resuming :: forall err eff r a. Member (Resumable err eff) r => (err -> Sem r a) -> Sem (eff ': r) a -> Sem r a Source #
Flipped variant of resume
.
resumingRe :: forall err eff r a. (err -> Sem (Resumable err eff ': r) a) -> Sem (eff ': r) a -> Sem (Resumable err eff ': r) a Source #
Flipped variant of resumeRe
.
resumeAs :: forall err eff r a. Member (Resumable err eff) r => a -> Sem (eff ': r) a -> Sem r a Source #
Variant of resume
that unconditionally recovers with a constant value.
(<!) :: forall err eff r a. Member (Resumable err eff) r => a -> Sem (eff ': r) a -> Sem r a Source #
Operator version of resumeAs
.
Since: 0.2.0.0
(!>) :: forall err eff r a. Member (Resumable err eff) r => Sem (eff ': r) a -> a -> Sem r a Source #
resume_ :: forall err eff r. Member (Resumable err eff) r => Sem (eff ': r) () -> Sem r () Source #
Convenience specialization of resume
that silently discards errors for void programs.
resumeWith :: forall err eff r a. Member (Resumable err eff) r => Sem (eff ': r) a -> Sem r a -> Sem r a Source #
Variant of resume
that unconditionally recovers with an action.
Since: 0.2.0.0
(!>>) :: forall err eff r a. Member (Resumable err eff) r => Sem (eff ': r) a -> Sem r a -> Sem r a Source #
Operator variant of resumeWith
.
Since: 0.2.0.0
resumingWith :: forall err eff r a. Member (Resumable err eff) r => Sem r a -> Sem (eff ': r) a -> Sem r a Source #
Variant of resuming
that unconditionally recovers with an action.
Since: 0.2.0.0
(<<!) :: forall err eff r a. Member (Resumable err eff) r => Sem r a -> Sem (eff ': r) a -> Sem r a Source #
Operator variant of resumingWith
.
Since: 0.2.0.0
resumeHoist :: forall err eff err' r a. Members [Resumable err eff, Stop err'] r => (err -> err') -> Sem (eff ': r) a -> Sem r a Source #
resumeHoistAs :: forall err eff err' r. Members [Resumable err eff, Stop err'] r => err' -> InterpreterFor eff r Source #
Variant of resumeHoist
that uses a constant value.
restop :: forall err eff r. Members [Resumable err eff, Stop err] r => InterpreterFor eff r Source #
Variant of resumeHoist
that uses the unchanged error.
resumeEither :: forall err eff r a. Member (Resumable err eff) r => Sem (eff ': r) a -> Sem r (Either err a) Source #
resumeOr :: forall err eff r a b. Member (Resumable err eff) r => Sem (eff ': r) a -> (a -> Sem r b) -> (err -> Sem r b) -> Sem r b Source #
Variant of resume
that takes a branch for error and success.
This allows the success branch to contain other resumptions.
Since: 0.2.0.0
resumingOr :: forall err eff r a b. Member (Resumable err eff) r => (err -> Sem r b) -> Sem (eff ': r) a -> (a -> Sem r b) -> Sem r b Source #
Variant of resuming
that takes a branch for error and success.
This allows the success branch to contain other resumptions.
Since: 0.2.0.0
resumeHoistError :: forall err eff err' r a. Members [Resumable err eff, Error err'] r => (err -> err') -> Sem (eff ': r) a -> Sem r a Source #
resumeHoistErrorAs :: forall err eff err' r a. Members [Resumable err eff, Error err'] r => err' -> Sem (eff ': r) a -> Sem r a Source #
Variant of resumeHoistError
that uses the unchanged error.
resumeError :: forall err eff r a. Members [Resumable err eff, Error err] r => Sem (eff ': r) a -> Sem r a Source #
Variant of resumeHoistError
that uses the unchanged error.