🥫 Cans
Simple, functional, composable containers like Maybe. Properly typed and supports pattern matching on Python 3.10+. Inspired by the containers in the Rust standard library.
Quickstart
>>> from cans import Just, Nothing, Maybe
>>> greeting: Maybe[str] = Just("Hello")
...
>>> def first(m: list[str]) -> Maybe[str]:
... return Just(m[0]) if m else Nothing()
...
>>> first(["howdy", "hi", "hello"]).map(str.title).unwrap()
"Howdy"
...
>>> # Python 3.10+ only
>>> match greeting:
... case Just(n):
... print(f"{greeting} world!")
... case Nothing():
... print("Hi world!")
Hello world!
Among the supported methods are flatmap, filter, zip, as well as the relevant collection APIs. See the documentation for a complete overview.
Todo
Other containers
Metadata
Release files for cans 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cans-0.1.3.tar.gz | 6.8 kB | Without provenance | Details for cans-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cans-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for cans-0.1.3-py3-none-any.whl |
Total release size: 14.5 kB
Release files / cans-0.1.3.tar.gz
| Download URL | cans-0.1.3.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
865983fc617f662518e0d163f6c9b71e7f8d4042e99b2b1b138f50a69bcc78f9
|
|
BLAKE2b-256 checksum How to use checksums |
481f0ff4ed5e9a312f6468fd8cb1b887f3930cf85522b0bd704b54606749e568
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.6 CPython/3.8.1 Darwin/20.3.0
|
Release files / cans-0.1.3-py3-none-any.whl
| Download URL | cans-0.1.3-py3-none-any.whl |
|---|---|
| Size | 7.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
161b7a71177f601b775ccc1429b7ad12624bd36462a9ffb9652fdb292226864f
|
|
BLAKE2b-256 checksum How to use checksums |
7cbec715e98b56bb5319be128ffd587e25c0117e5467f890b7fbc1affc1389aa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.6 CPython/3.8.1 Darwin/20.3.0
|
Security for cans 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.