Skip to main content

A Python implementation of a Maybe type that represents potentially missing values

Project description

maybedata

This is a package that implements a Maybe data type in Python that represents values that might or might not exist.

It is implemented as a class hierarchy with an abstract base class Maybe. This class is not constructible, but can be called to construct members of its subclasses, Just and Nothing.

All methods are documented, feel free to call help() on the classes!

Call Maybe(value) or Just(value) to create a value that is present.

Call Maybe() or Nothing() to create a missing value.

Check maybe.present to find out if a value is present.

Access maybe.value to get the value if it is present.

Call maybe.assume_present() to raise an exception if the value is not present.

Call maybe.get(default) to get the value or a default value.

Maybe and Just are generic classes if you use type hinting.

Just and Nothing support pattern matching.

Maybe, Just, and Nothing support len(), bool(), hash(), iter(), in, and ==.

The method maybe.alternatively() can be expressed using |.

The method maybe.then() can be expressed using >>.

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

maybedata-0.6.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

maybedata-0.6-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file maybedata-0.6.tar.gz.

File metadata

  • Download URL: maybedata-0.6.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.28.1

File hashes

Hashes for maybedata-0.6.tar.gz
Algorithm Hash digest
SHA256 6156d4fa8d0c3a958a4152451fcfcb670c14ca5c3c31411b9afbe0926382e7f6
MD5 883df14eded6a769f08ee795e4a472dc
BLAKE2b-256 9a8551de9692416de80a35ca4d4644220185cce618af988291d62e69aed1c378

See more details on using hashes here.

File details

Details for the file maybedata-0.6-py3-none-any.whl.

File metadata

  • Download URL: maybedata-0.6-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.28.1

File hashes

Hashes for maybedata-0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 9cb6ef897bfb66a9399241d7cea32b4b2987b3ae1dceec5b20a885eb979154ef
MD5 85da3867ffee85655c21bc57ef07f2a4
BLAKE2b-256 78a96ae32ba868983f3ef04bbb1c3ae0659901ff6b7d44422bf88ef4459366cd

See more details on using hashes here.

Supported by

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