dry-monads
Monads for python made simple and safe.
Features
- Provides primitives to write declarative business logic
- Fully typed with annotations and checked with
mypy, allowing you to write type-safe code as well - No operator overloading or other unpythonic stuff that makes your eyes bleed
Installation
pip install dry-monads
What's inside?
We have several the most iconic monads inside:
- Result, Failure, and Success (also known as
Either,Left, andRight) - Maybe, Some, and Nothing
We also care about code readability and developer experience, so we have included some useful features to make your life easier:
Example
from dry_monads.do_notation import do_notation
from dry_monads.either import Result, Success, Failure
class CreateAccountAndUser(object):
"""Creates new Account-User pair."""
@do_notation
def __call__(self, username: str, email: str) -> Result['User', str]:
"""Can return a Success(user) or Failure(str_reason)."""
user_schema = self._validate_user(username, email).unwrap()
account = self._create_account(user_schema).unwrap()
return self._create_user(account)
# Protected methods
# ...
We are covering what's going on in this example in the docs.
Inspirations
This module is heavily based on:
Metadata
Release files for dry-monads 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| dry-monads-0.2.0.tar.gz | 8.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dry_monads-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 31.2 kB
Release files / dry-monads-0.2.0.tar.gz
| Download URL | dry-monads-0.2.0.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dde7d4160473b469032719cdf8449d716501de379de653d053b6909de4a84477
|
|
BLAKE2b-256 checksum How to use checksums |
a8b97eeb4827ea3f1c97020923263b4c3457a1fc8f6bbdb14f487392cb7705bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/0.12.11 CPython/3.6.6 Darwin/18.2.0
|
Release files / dry_monads-0.2.0-py3-none-any.whl
| Download URL | dry_monads-0.2.0-py3-none-any.whl |
|---|---|
| Size | 22.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
64828e97d308052e95bd1233e7bf5b7a1f76c10e18a0d565b6f763a8c17f8cfe
|
|
BLAKE2b-256 checksum How to use checksums |
b60e5ad9a35e1c1b500637230416d13d69f723777973192e6e94102769abed47
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/0.12.11 CPython/3.6.6 Darwin/18.2.0
|
Security for dry-monads 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.