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.4.tar.gz (7.0 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.4-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for maybedata-0.4.tar.gz
Algorithm Hash digest
SHA256 91e5b8ce162eb8efec68160f13c3cf9f1d978edc1d31b3d37dd2890b66157d12
MD5 1f798b329d99bb355282abca5de75302
BLAKE2b-256 0073a846721cf34c2a0c5fe5c82218c55c5624a747d8e67e20bcd2e02d6f693f

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for maybedata-0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 9c045b39889b5dfb383546660aa8e4742914c3e6d8b7885bdae1a476c84ac288
MD5 00554167b3f778e4439cd3c8fe6b0264
BLAKE2b-256 cb94027be71b1a13bcf9b9b2de56f4324f84be9556dd3e6b623241a226998aaa

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