Monads used for handling Errors. Contains Attempt and Option.
Project description
Monadic Error
by Ian Kollipara
This is a small library containing 2 monads for handling errors in Python: Attempt (Either) and Option (Maybe). These two are chosen for their usefulness in handling errors gracefully, and for the ability to slot in nicely with python. Both monads work with Python 3.10 pattern matching, and as well as MyPy exhaustive pattern matching.
All monads implement map
, flatMap
, and unwrap_or
. These all aid in their use in python.
In addition there are a few utility functions for working with the objects during the execution of the program.
Attempt
Attempt is the Either monad. The name was chosen to signify how it should be used. There are two constructors for this: Success and Failure. Use them as their name denotes.
Option
Option is the Maybe Monad. The name was chosen to signify how it should be used. There are two constructors for this: Some and Nothing. Use them as their name denotes.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for monadic_error-2.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7b356d8a407cad0674bdadeddc13ee22c33192c0a087a51363943c6eaeab2a0 |
|
MD5 | bd7046d051fdce99db8ec776dbe087ac |
|
BLAKE2b-256 | 897df49ea7a14792e90b281c5cc4d86866dcbeb939b21725ea1bf523baa1fd67 |