liveBook · Manning

Metaprogramming

As explained in Functional Design and Architecture: Examples in Haskell

Metaprogramming is the manipulation or generation of program representations to produce or transform code, often during compilation.

Metaprogramming manipulates abstract code that declares code to be generated. When a compiler encounters those instructions, it produces additional code at compile time. This can make a codebase more expressive and flexible, but the generated code is embedded implicitly and can be difficult to inspect. Use it carefully, especially when understanding what code will actually run matters. section 2.1.2

How Functional Design and Architecture: Examples in Haskell covers it

How deep it goes
Defines abstract-code manipulation and compile-time generation, then cautions that generated output can be difficult to inspect.
What you can do after
Evaluate metaprogramming as a design tool while accounting for the difficulty of inspecting generated code.
How it connects
Connects abstract-code manipulation to compilers, which generate additional code at compile time.

Also explained in

Compare how 3 books explain metaprogramming →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Functional Design and Architecture: Examples in Haskell. The section links point to the parts of the book it draws on.