std.effect.error

Implementation of the Error effect

Types

type Error e r a = 
    | Error e
    .. r

The Error effects adds "exceptions" to the Eff monad

Values

let catch eff handler : forall a r .
        forall e .
            Eff [| error : Error e | r |] a
                -> (e -> Eff [| error : Error e | r |] a)
                -> Eff [| error : Error e | r |] a

Catches an "exception", allowing the effect to continue executing

let throw e : forall a r e . e -> Eff [| error : Error e | r |] a

Throws the error e

let ok_or_throw r : forall r t e . Result e t -> Eff [| error : Error e | r |] t

Moves a Result into the Eff monad

let some_or_throw e o : forall r a e . e -> Option a -> Eff [| error : Error e | r |] a

let run_error eff : forall a r .
        forall e . Eff [| error : Error e | r |] a -> Eff [| | r |] (Result e a)

Eliminates the Error effect and returns a Result