A small, practical playground for learning functional programming concepts in Python through concise examples and incremental exercises.
Functional programming (FP) can feel abstract when presented only as theory or toy examples. This repository focuses on small, concrete, and reusable patterns that you can apply in real projects. The goal is to show how FP ideas improve code clarity, safety, and composability—without requiring a new language.
- Provide minimal, readable implementations of core FP concepts in Python.
- Explain why and when each concept is useful.
- Offer hands-on examples you can run and modify quickly.
- Keep the code small enough to study in one sitting.
Current modules:
functor.py— a basicFunctorwithmapmaybe.py— aMaybetype to represent optional values safelyeither.py— anEithertype for success/error-style modeling
Each module includes a small main() demonstrating usage.
- Python 3.12.10+
- Functor — Learn how
mapapplies a transformation without changing the container. - Maybe — Avoid
Nonechecks scattered across your code. - Either — Model success/failure explicitly without exceptions.