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.3.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.3-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: maybedata-0.3.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.3.tar.gz
Algorithm Hash digest
SHA256 b51081ec7511ccc49dbf789ff4d1067cb2db68627de1e0af53a9f82ca155ea78
MD5 cacdf557c4181c32d14ec56d52761e95
BLAKE2b-256 f141222e292cccdaa8a4a02a542483cabe03bd300d9273ff221f53037f702528

See more details on using hashes here.

File details

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

File metadata

  • Download URL: maybedata-0.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a8400bbf60c38d6e891880ca80ec9e962b4f4d255e3069417d79cdf8cf4dd582
MD5 ce22943eacc52dca1594f92644b347d8
BLAKE2b-256 a1f6a6a47e2dc5fc816e4d8d624f3835b72921628ba1839094f797df39afdc20

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