HeadlinesBriefing favicon HeadlinesBriefing.com

Teaching functional programming through a kid's game

Hacker News •
×

When Brent, an associate professor at Hendrix College, was reading Janis Voigtländer’s habilitation on free theorems, his six‑year‑old son asked what he was reading. Brent replied it was a long story about free theorems and then broke down the notion of a function as a simple input‑output machine. The child grasped the idea quickly, even suggesting words as inputs.

Brent turned the explanation into a game he called the function machine game: he thinks of a hidden function and the child supplies inputs, receiving outputs until he can guess the rule. The game sparked nonstop play during car rides and showers, and the boy soon identified increment functions, constant functions, and even a “ignore input” function that returns the same value regardless of argument.

The experiment revealed how abstract concepts like polymorphism and constant functions become tangible when framed as everyday puzzles. Brent noticed his students later struggled with constant functions in lambda calculus for the same reason his son did—expecting the input to appear in the output. The anecdote shows that playful inquiry can demystify core functional programming ideas.