Skip to main content

Monads for python made simple and safe.

Project description

dry-monads

wemake.services Build Status Coverage Status Documentation Status Python Version Dependencies Status 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:

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:

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

dry-monads-0.1.1.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

dry_monads-0.1.1-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file dry-monads-0.1.1.tar.gz.

File metadata

  • Download URL: dry-monads-0.1.1.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.11 CPython/3.6.6 Darwin/18.2.0

File hashes

Hashes for dry-monads-0.1.1.tar.gz
Algorithm Hash digest
SHA256 fdc58902a95b667a59235246e7321a9bfa29428d4d9fde2a8a0213b4010d617e
MD5 f488e94b956b4473c59974970d828bc0
BLAKE2b-256 db4965a7966ce57b856aa5e7737b4ec779016028afe5b0f3514147406222d385

See more details on using hashes here.

File details

Details for the file dry_monads-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: dry_monads-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.11 CPython/3.6.6 Darwin/18.2.0

File hashes

Hashes for dry_monads-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 43ca6958145e2024ac940268db3a1a7a5ee787c2468463728dc0dc3bd206cb5c
MD5 9182688390d058e169e873b1908049bb
BLAKE2b-256 0e26dfd220f12762a03f5cdf1261f26fc3b9e2f4f86d223f40d6e2f4d3b8b600

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page