Andres Löh is a Haskell consultant and co-owner of Well-Typed LLP. He is based in Regensburg, Germany. He started using Haskell in 1997, when being an undergraduate student of mathematics in Konstanz, and has been an enthusiastic functional programmer ever since. Andres obtained a PhD in Computer Science from Utrecht University in 2004, on extending the Haskell language with capabilities for datatype-generic programming. After having been a university lecturer for several years, he joined Well-Typed in 2010.
Andres is very interested in applying functional programming to real-world problems, and in particular in datatype-generic programming, domain-specific languages, (dependent) type systems, parallel and concurrent programming, and the theory of version control.
One of the big promises of Haskell is programming at a high level of abstraction while getting good performance. To this end, GHC's optimiser is doing an impressive amount of work, by employing e.g. partial evaluation and rewrite rules to remove intermediate representations.
However, relying on the optimiser is nevertheless fragile. Especially when composing high-level abstractions, small, innocent-looking changes to a program can often have a significant and nearly unpredictable impact on the final run-time performance.
A different option is to employ staging. In a staged program, code is annotated to execute either at compile-time or at run-time, allowing us to ensure that parts of the code are executed entirely during compilation and therefore have no chance to clutter the compiled output. Examples of this technique are manifold and reach from unrolling a loop (or list) to fusing away intermediate tree like structures on composition to advanced examples such as generating highly efficient parsers, stream processors, generic functions or compilers.
In GHC, staging is available in the form of typed quotations and splices — a somewhat neglected yet very elegant subset of Template Haskell.
In this talk, I will give an introduction to staged programming in Haskell, and show a few examples of how staging can help make programs more reliably efficient.