HeadlinesBriefing favicon HeadlinesBriefing.com

Katharos: Functional Programming & Concurrency for Python

Hacker News •
×

Katharos is a functional programming and concurrency library for Python that bundles algebraic abstractions—Functor, Applicative, Monad, Semigroup, and Monoid—with concrete types such as Maybe, Result, Immutable List, and IO. All are built on a single functional core.\n\nThe library treats errors, effects, and concurrent communication as composable, type‑safe values. A hand‑off that fails returns a Result, turning a closed channel into a value rather than an exception.

Install with pip or uv and import modules from katharos.types and katharos.syntax_sugar.\n\nTypical patterns shift from scattered None checks and nested try/except blocks to do‑notation that short‑circuits on Nothing and pipelines that chain Result values. For example, parsing an integer becomes a simple success or failure value, and the Result.catch decorator turns exception‑raising functions into Result‑returning ones without boilerplate.\n\nConcurrency is provided via a Go‑style CSP model: launch work with csp.go, communicate over typed Channels, and receive values as Result. The runtime automatically supplies a threading backend, allowing easy re‑targeting.

Documentation, tutorials, and the MIT license are available on katharos.readthedocs.io.