An open API service indexing awesome lists of open source software.

https://github.com/mhbxyz/fptk

Pragmatic functional programming helpers for Python.
https://github.com/mhbxyz/fptk

functional functional-programming python

Last synced: 2 months ago
JSON representation

Pragmatic functional programming helpers for Python.

Awesome Lists containing this project

README

          


fptk


Pragmatic functional programming for Python 3.13+


PyPI
Python
CI
License

---

## Install

```bash
pip install fptk
```

## Quick Example

```python
from fptk.core.func import pipe
from fptk.adt.option import Some, NOTHING
from fptk.adt.result import Ok, Err

# Compose transformations
result = pipe(5, lambda x: x + 1, lambda x: x * 2) # 12

# Handle absence explicitly
name = Some("alice").map(str.upper).unwrap_or("anonymous") # "ALICE"

# Type-safe error handling
def parse(s: str) -> Result[int, str]:
try:
return Ok(int(s))
except ValueError:
return Err(f"invalid: {s}")

parse("42").map(lambda x: x * 2) # Ok(84)
```

## Documentation

**[mhbxyz.github.io/fptk](https://mhbxyz.github.io/fptk)**

## License

MIT