Hands-On Learning

"You look at where you're going and where you are and it never makes sense, but then you look back at where you've been and a pattern seems to emerge."

– Robert M. Pirsig, Zen and the Art of Motorcycle Maintenance


Reading about functional programming is one thing. Writing it is another entirely.

These tutorials exist because understanding emerges from doing. You will encounter exercises where you replace answerRequired() with working code. Tests will fail, red and insistent, until your solution is correct. The failure is not punishment; it is feedback. Each red test is a question; each green test is comprehension made concrete.

The pattern Pirsig describes applies precisely here. Midway through an exercise on Applicative composition, the relationship between map and ap may feel arbitrary. Three tutorials later, building a validation pipeline, the pattern clicks. You look back at where you've been, and suddenly the earlier struggles make sense. This is not a flaw in the learning process. It is the learning process.

Eight journeys are available, each designed to be completed in 22-40 minutes. Do one per sitting. Let concepts consolidate before moving on.

Expect to struggle. Expect moments of confusion. These are not signs that something is wrong. They are signs that learning is happening.


The Learning Loop

    ┌─────────────────────────────────────────────────────────────┐
    │                                                             │
    │    READ  ──────►  WRITE  ──────►  RUN  ──────►  OBSERVE     │
    │      │              │              │               │        │
    │      │              │              │               │        │
    │      ▼              ▼              ▼               ▼        │
    │   Exercise      Replace        Execute          Red or      │
    │   description   answerRequired()  test          Green?      │
    │                                                             │
    │                         │                                   │
    │                         ▼                                   │
    │              ┌──────────┴──────────┐                        │
    │              │                     │                        │
    │           GREEN                   RED                       │
    │         (Next exercise)     (Read error, iterate)           │
    │                                                             │
    └─────────────────────────────────────────────────────────────┘

The loop is simple. The understanding it produces is not.


Eight Journeys

JourneyFocusDurationExercises
Core: FoundationsHKT simulation, Functor, Applicative, Monad~38 min24
Core: Error HandlingMonadError, concrete types, real-world patterns~30 min20
Core: AdvancedNatural Transformations, Coyoneda, Free Applicative~26 min16
Effect APIEffect paths, ForPath, Effect Contexts~65 min15
Optics: Lens & PrismLens basics, Prism, Affine~40 min30
Optics: TraversalsTraversals, composition, practical applications~40 min27
Optics: Fluent & FreeFluent API, Free Monad DSL~37 min22
Optics: Focus DSLType-safe path navigation~22 min18

Start with whichever interests you most. The Learning Paths guide suggests sequences for different goals.


What You'll Learn

In This Chapter

  • Core Types Journeys – Three journeys building from basic Kind<F, A> wrapping through error handling to advanced patterns like Coyoneda and Free Applicative.
  • Effect API Journey – Learn the recommended user-facing API for working with functional effects.
  • Optics Journeys – Four journeys progressing from simple Lens operations through Traversals, the Free Monad DSL, and the Focus DSL.
  • Learning Paths – Curated sequences of journeys for different goals and time budgets.
  • Solutions Guide – When you're genuinely stuck, reference implementations are available. Try to struggle first; the learning happens in the struggle.
  • Troubleshooting – Common errors and their solutions.

Chapter Contents

  1. Interactive Tutorials - Getting started with the tutorial system
  2. Core Types
  3. Effect API
  4. Optics
  5. Learning Paths - Recommended journey sequences
  6. Solutions Guide - Reference implementations
  7. Troubleshooting - Common issues and solutions

Next: Interactive Tutorials