Robust, composable, functional containers
Project description
Composable, robust, functional containers like Maybe. Properly typed and supports pattern matching on Python 3.10+.
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.title()} world!")
... case Nothing():
... print("Hi world!")
Hello world!
Among the supported methods are flatmap, filter, zip, as well as the relevant collection APIs.
Todo
Other containers
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
cans-0.1.1.tar.gz
(6.4 kB
view hashes)
Built Distribution
cans-0.1.1-py3-none-any.whl
(7.1 kB
view hashes)