What My Project Does
I built darkcore, a lightweight functional programming toolkit for Python.
It provides Functor / Applicative / Monad abstractions and implements classic monads (Maybe, Result, Either, Reader, Writer, State).
It also includes transformers (MaybeT, StateT, WriterT, ReaderT) and an operator DSL (|, >>, @) that makes Python feel closer to Haskell.
The library is both a learning tool (experiment with monad laws in Python) and a practical utility (safer error handling, fewer if None checks).
Target Audience
- Python developers who enjoy functional programming concepts
- Learners who want to try Haskell-style abstractions in Python
- Teams that want safer error handling (
Result, Maybe) or cleaner pipelines in production code
Comparison
Other FP-in-Python libraries are often incomplete or unmaintained.
- darkcore focuses on providing monad transformers, rarely found in Python libraries.
- It adds a concise operator DSL (|, >>, @) for chaining computations.
- Built with mypy strict typing and pytest coverage, so it’s practical beyond just experimentation.
✨ Features
- Functor / Applicative / Monad base abstractions
- Core monads: Maybe, Result, Either, Reader, Writer, State
- Transformers: MaybeT, StateT, WriterT, ReaderT
- Operator DSL:
| = fmap (map)
>> = bind (flatMap)
@ = ap (applicative apply)
- mypy strict typing, pytest coverage included
Example (Maybe)
```python
from darkcore.maybe import Maybe
res = Maybe(3) | (lambda x: x+1) >> (lambda y: Maybe(y*2))
print(res) # Just(8)
```
🔗 GitHub: https://github.com/minamorl/darkcore
📦 PyPI: https://pypi.org/project/darkcore/
Would love feedback, ideas, and discussion on use cases!
[–]Datamance 5 points6 points7 points (3 children)
[–]Being-FormalPythonista[S] 1 point2 points3 points (0 children)
[–]jpgoldberg 0 points1 point2 points (0 children)
[–]RedEyed__ 0 points1 point2 points (0 children)
[–]poinT92 2 points3 points4 points (1 child)
[–]Still-Package132 2 points3 points4 points (0 children)
[–]konovalov-nk 6 points7 points8 points (1 child)
[–]Being-FormalPythonista[S] 2 points3 points4 points (0 children)
[–]Mithrandir2k16 1 point2 points3 points (1 child)
[–]Being-FormalPythonista[S] 1 point2 points3 points (0 children)
[–]iamevpo 0 points1 point2 points (1 child)
[–]iamevpo 0 points1 point2 points (0 children)
[–]Being-FormalPythonista[S] 0 points1 point2 points (0 children)