Copyright | (c) Marcus Völker 2017-2018 |
---|---|
License | MIT |
Maintainer | marcus.voelker@rwth-aachen.de |
Safe Haskell | Safe |
Language | Haskell2010 |
This module describes DoubleContinuations, which are Continuations that may have succeeded or failed. Instead of just taking a single function (a -> r) -> r to execute after the computation has run, a double continuation takes two functions: one to call in case of success and one to call in case of error This allows for easy implementation of exception handling and structuring control flow in a pass/fail manner
Documentation
The double continuation. Takes two functions, one to invoke if the computation is successful, one if it errors
Instances
Monad (DCont r e) Source # | Binding a Continuation means running it, then feeding the result into f to generate a new continuation, and running that |
Functor (DCont r e) Source # | via Monad/Functor laws |
MonadFail (DCont r e) Source # | Failing a Continuation means returning a continuation that always fails. |
Defined in Control.DoubleContinuations | |
Applicative (DCont r e) Source # | via Monad/Applicative laws |
Alternative (DCont r e) Source # | An empty alternative just fails with an undefined error. Branching means first trying one, and in case of failure, the other |
:: e | The error to return |
-> DCont r e a |
Generates a continuation that always fails. For a continuation that always succeeds, see return
dfix :: (Either e a -> DCont (Either e a) e a) -> DCont r e a Source #
MonadFix
-analogue for DoubleContinuations. Since it doesn't fit in the signature of mfix
, it is defined separately