Skip to content
Latchkey

What Is Defunctionalization?

Defunctionalization is a program transformation that eliminates higher-order functions by representing each function value as a distinct data constructor and routing all calls through one apply function that pattern matches on the constructor. The behavior that was a function becomes data plus a central dispatcher. The result is a first-order program with no function-valued arguments.

Why it matters

Defunctionalization lets higher-order code be compiled to languages or targets without first-class functions, and it makes the set of possible behaviors explicit. It is a useful technique in compilers and whole-program analyses.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →