Skip to content

MonadError

funstruct.typeclasses.monad_error

MonadError — a Monad that can raise and handle typed errors.

pure(a) — put a value ON the success rail raise_error(e) — put a value ON the error rail bind(f) — continue along the success rail handle_error_with(f) — recover FROM the error rail

MonadError

Bases: Monad

raise_error + handle_error_with.

Source code in funstruct/typeclasses/monad_error.py
17
18
19
20
21
22
23
24
class MonadError(Monad):
    """raise_error + handle_error_with."""

    @abstractmethod
    def raise_error(self, error) -> object: ...

    @abstractmethod
    def handle_error_with(self, fa, f: Callable) -> object: ...