How to teach functional programming to a beginner

Teaching functional programming to a beginner works best when you teach data first and vocabulary last. The person in front of you does not need a lecture on category theory; they need to write a function, watch it return a value, and feel that nothing else moved. What follows is a sequence that keeps that feeling going for the first few weeks.

Start with data, not abstractions

Show a list of records and ask what should come out the other side. Draw it once by hand. Only then write the transformation, and keep the first version long and obvious: separate functions, each doing one step, each with a name you could read aloud. Abstraction can wait until the beginner has felt the repetition it would remove.

Nothing kills momentum faster than a first lesson that opens with a definition of a monad. If the topic comes up, park it with a sentence: a way to chain steps that carry some extra context. Then move on.

Make the feedback loop tiny

Keep the beginner working in a place where running something takes seconds: a scratch file, a REPL, a single test. If they have to wait for a build or a deploy, the lesson becomes about tooling. Have them write an assertion right next to the function so the answer appears where they are looking.

  • One function per exercise, ten lines or fewer.
  • A working example they can change and break.
  • Tests they can run before you arrive, so the session starts with an answer, not a setup.

Teach the pure and impure boundary first

Before recursion and composition, teach the difference between a calculation and an action. Ask them to sort the functions in a small script into two piles. This single distinction explains why some functions are annoying to test and others are trivial, and it gives every later lesson a place to hang.

Let them write ugly code on purpose

Beginners copy the polished snippets they find online and then feel bad about their own attempts. Give permission to write a clumsy recursive function, a nested pipeline, a direct translation of a loop. Then improve it together, on the same day, and name what changed. Comparing two versions they wrote teaches far more than reading the elegant one first.

What to leave out of the first month

Skip optics, free monads, category theory, and anything that needs a second file to demonstrate. Leave performance discussions for later too; the first month is about correctness and comfort. Do not skip pattern matching, immutability, or the habit of writing a type signature before a body, because those pay off immediately.

How do I know they have understood it?

Ask them to explain, in their own words, why a function with no side effects is easier to test. A correct answer in plain language matters more than a polished exercise.

What if they prefer their old style?

Good. Let them keep the parts that work and try the new style only where it clearly helps. Forced conversion produces people who can recite terms and still write the same programs.

Teach one idea at a time, keep the examples small enough to finish in a session, and let the beginner’s own code be the textbook. That is slower on paper and considerably faster in practice.