Metadata-Version: 2.4
Name: kleisli
Version: 0.1.0
Summary: A small, law-verified functional programming toolkit for Python — Functor, Applicative, Maybe, Either, Writer.
Author-email: Miroslav Nikolic <mick.nikolic2023@gmail.com>, Bojana Dimic Surla <bdimicsurla@raf.rs>
License-Expression: MIT
License-File: LICENSE
Keywords: applicative,category theory,functional programming,functor,monad
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Typing :: Typed
Requires-Python: >=3.9
Provides-Extra: test
Requires-Dist: pytest; extra == 'test'
Description-Content-Type: text/markdown

# kleisli

A small, law-verified functional programming toolkit for Python.

`kleisli` provides `Functor`, `AFunctor` (Applicative), and the `Maybe`,
`Either`, and `Writer` monads. Every law (functor identity/composition,
monad left/right identity, monad associativity, applicative homomorphism/
interchange) is checked by the test suite, not just assumed.

## Install

```bash
pip install -e .
```

## Usage

```python
from kleisli import Maybe, Either, Right, Left, Writer

# Maybe: short-circuits on Nothing, catches exceptions in bind
result = Maybe.pure(4).bind(lambda x: Maybe(x / 2))

# Either: Right holds success, Left holds an error; bind short-circuits on Left
result = Right(10).bind(lambda x: Right(x / 0))  # -> Left(ZeroDivisionError(...))

# Writer: pairs a value with an accumulated log
w = Writer.pure(1).bind(lambda x: Writer(x + 1, ["incremented"]))
```

See [`examples/`](examples/) for a scikit-learn `GridSearchCV` pipeline built
with `AFunctor` + `Either`, and a lock-free parallel accumulation example
built with `Writer` and `ThreadPoolExecutor`.

## Development

```bash
pip install -e ".[test]"
pytest
```
