Skip to main content

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

Reason this release was yanked:

Source has accidentally been deleted from source control

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: maybedata-0.5.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.5.tar.gz
Algorithm Hash digest
SHA256 722a2c0bd7fd73e962be004c926a3d4fecd3f12c9b1ed975e122901732d0dc42
MD5 1533a2919eb9cf20a5a13a1de63546eb
BLAKE2b-256 ac3d7eeccb7ca86b182a736302742650a419df331650aeba8aa9459397183e57

See more details on using hashes here.

File details

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

File metadata

  • Download URL: maybedata-0.5-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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 40c2a2969215fb602dcf73637c79fe4ad4c593aa24b335b96552c13955249581
MD5 b8d04e71d56f9820280e7592d7e17889
BLAKE2b-256 30059b0317a342586a903e31d6f5330e62035bd4108327e13d9c5786e0dfb794

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