Catch an error in ExceptT, applying a handler.
$$\text{catchError}(ma, h) : \text{ExceptT}\ \varepsilon\ m\ \alpha$$
Runs ma; if it throws error e, runs h e instead.
Alias for Lean's tryCatch pattern.
Equations
- Control.Monad.Except.catchError ma handler = ExceptT.mk do let __do_lift ← ma.run match __do_lift with | Except.ok a => pure (Except.ok a) | Except.error e => (handler e).run
Instances For
Map over the inner computation and error/value types.
$$\text{mapExceptT}(f, ma) : \text{ExceptT}\ \varepsilon'\ n\ \beta$$
where $f : m\ (\text{Except}\ \varepsilon\ \alpha) \to n\ (\text{Except}\ \varepsilon'\ \beta)$.
Equations
- Control.Monad.Except.mapExceptT f ma = ExceptT.mk (f ma.run)
Instances For
Map over the error type, leaving the value unchanged.
$$\text{withExceptT}(f, ma) : \text{ExceptT}\ \varepsilon'\ m\ \alpha$$
where $f : \varepsilon \to \varepsilon'$.
Equations
- Control.Monad.Except.withExceptT f ma = ExceptT.mk (Except.mapError f <$> ma.run)
Instances For
Unwrap an ExceptT computation.
$$\text{runExceptT} : \text{ExceptT}\ \varepsilon\ m\ \alpha \to m\ (\text{Except}\ \varepsilon\ \alpha)$$
Alias for ExceptT.run.
Equations
Instances For
runExceptT of liftEither (.ok a) yields .ok a.
$$\text{runExceptT}(\text{liftEither}(\text{ok}\ a)) = \text{pure}(\text{ok}\ a)$$
runExceptT of liftEither (.error e) yields .error e.
$$\text{runExceptT}(\text{liftEither}(\text{error}\ e)) = \text{pure}(\text{error}\ e)$$