Skip to main content

functorial

PyPI - Version PyPI - Python Version


Functional-programming concepts for Python: typeclasses (Functor, Applicative, Monad, Foldable, Traversable, Alternative, ...), standard FP data types (Maybe, Either, List, Dict, NTuple, trees, IO, Reader, Writer, State), and a profunctor-based optics library (lenses, prisms, traversals, folds, isos, and their indexed variants).

This is an evolving, educational project — the API is still settling and not everything on the roadmap is implemented yet. Feedback and issues are welcome.

Installation

pip install functorial
# or
uv add functorial

Requires Python 3.12+.

Quick taste

from functorial.maybe import Some, Nothing
from functorial.optics.lens import lens
from functorial.optics.getter import view
from functorial.optics.setter import over

# Maybe: a Functor/Applicative/Monad/Traversable
Some(3).map(lambda x: x + 1)     # Some(4)
Nothing().map(lambda x: x + 1)   # Nothing()

# Optics: compose lenses with @, act on them with view/over
fst = lens(lambda s: s[0], lambda s, b: (b, s[1]))
snd = lens(lambda s: s[1], lambda s, b: (s[0], b))

view(fst)((1, 2))                     # 1
over(fst @ snd, str)(((1, 2), 3))     # ((1, '2'), 3)

Development

uv sync
uv run pytest

License

MIT — see LICENSE.

Release files for functorial 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for functorial 0.1.3
File Size Uploaded
functorial-0.1.3.tar.gz 127.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for functorial 0.1.3
File Interpreter ABI Platform
functorial-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 239.0 kB

Release files / functorial-0.1.3.tar.gz

Download URL functorial-0.1.3.tar.gz
Size 127.5 kB
Tags Source
SHA-256 checksum
How to use checksums
820b73f0b8b6f7c21558fc48650341d91699b8591702274f4aed4491ebdaf512
BLAKE2b-256 checksum
How to use checksums
cacf4ea14ee4a4eb4ab2c1f255a82ada605174c2d3fbcc52992b2770b97d1ff5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / functorial-0.1.3-py3-none-any.whl

Download URL functorial-0.1.3-py3-none-any.whl
Size 111.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b76be927573dad348745007f08e7d691e438c28a90b371ea3c4ad12609da5eda
BLAKE2b-256 checksum
How to use checksums
f9c555d9b7c5c67fc801a517c0bd7408a69f2a9236ebeaf5ebfe0838971d2770
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

0.1.4

2 release files

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page