Skip to main content

functorial

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.2

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.2
File Size Uploaded
functorial-0.1.2.tar.gz 126.3 kB Details

Built distribution (wheel)

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

Total release size: 237.3 kB

Release files / functorial-0.1.2.tar.gz

Download URL functorial-0.1.2.tar.gz
Size 126.3 kB
Tags Source
SHA-256 checksum
How to use checksums
0b54aed29447251f586816ba033e2bbb3f5afaf4c9cdda5a6bc8da80a84bdef4
BLAKE2b-256 checksum
How to use checksums
ba26d64827a6b458ad6bc06a0831ee634f77c384cc78d614ed6e7b299fa887c8
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.2-py3-none-any.whl

Download URL functorial-0.1.2-py3-none-any.whl
Size 111.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7489c7e9e194078a0f07c0b8377725834147d2feac41cf037c020bc82b6e48c8
BLAKE2b-256 checksum
How to use checksums
0b25db2d81b7fccff8df2fcec45501ea43aa690bfad0224bc3859a55c36fa334
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

0.1.3

2 release files

This release

0.1.2 This release

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