extensible-effects-1.2.1: An Alternative to Monad Transformers

Safe HaskellTrustworthy



Effects which fail.



data Fail v Source

Fail represents effects which can fail. This is akin to the Maybe monad.

die :: Member Fail r => Eff r ()Source

Makes an effect fail, preventing future effects from happening.

runFail :: Eff (Fail :> r) a -> Eff r (Maybe a)Source

Runs a failable effect, such that failed computation return Nothing, and Just the return value on success.

ignoreFail :: Eff (Fail :> r) a -> Eff r ()Source

Ignores a failure event. Since the event can fail, you cannot inspect its return type, because it has none on failure. To inspect it, use runFail.



:: Eff r a

The computation to run on failure.

-> Eff (Fail :> r) a

The computation which can fail.

-> Eff r a 

Given a computation to run on failure, and a computation that can fail, this function runs the computation that can fail, and if it fails, gets the return value from the other computation. This hides the fact that a failure even happened, and returns a default value for when it does.