Skip to content

Latest commit

 

History

History
64 lines (39 loc) · 1.99 KB

File metadata and controls

64 lines (39 loc) · 1.99 KB

functional-python

A small, practical playground for learning functional programming concepts in Python through concise examples and incremental exercises.

Why this repo?

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.

Goals

  • 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.

What’s inside

Current modules:

  • functor.py — a basic Functor with map
  • maybe.py — a Maybe type to represent optional values safely
  • either.py — an Either type for success/error-style modeling

Each module includes a small main() demonstrating usage.

Requirements

  • Python 3.12.10+

Suggested learning path

  1. Functor — Learn how map applies a transformation without changing the container.
  2. Maybe — Avoid None checks scattered across your code.
  3. Either — Model success/failure explicitly without exceptions.