The Glorious Glasgow Haskell Compilation System, more commonly known as the Glasgow Haskell Compiler or GHC, is an open source native code compiler for the functional programming language Haskell. The lead developers are Simon Peyton Jones and Simon Marlow.
Peyton Jones, as well as Simon Marlow, later moved to Microsoft Research in Cambridge, England, where they continue to be primarily responsible for developing GHC. GHC also contains code from more than sixty other contributors.
GHC's front end — incorporating the lexer, parser and typechecker — is designed to preserve as much information about the source language as possible until after type inference is complete, toward the goal of providing clear error messages to users. In its last phase, the front end desugars Haskell into a typed intermediate language known as "Core" (based on System F, extended with let and case expressions). Recently, Core was extended to support generalized algebraic datatypes in its type system, and is now based on an extension to System F known as System FC.
In the tradition of type-directed compilation, GHC's simplifier, or "middle end", where most of the optimizations implemented in GHC are performed, is structured as a series of source-to-source transformations on Core code. The analyses and transformations performed in this compiler stage include demand analysis (a generalization of strictness analysis), application of user-defined rewrite rules (including a set of rules included in GHC's standard libraries that performs foldr/build fusion), unfolding (called "inlining" in more traditional compilers), let-floating, an analysis that determines which function arguments can be unboxed, constructed product result analysis, specialization of overloaded functions, as well as a set of simpler local transformations such as constant folding and beta reduction.
The final stage of the simplifier transforms Core code into STG (short for "Spineless Tagless G-machine"), a lower-level intermediate language. Like Core, STG is itself a functional language. STG also corresponds to an abstract machine. GHC's back end performs transformations on STG before translating it into C, C--, or native machine code (the traditional "code generation" phase). Emitted C or C-- code may then be used as an intermediate language before compiling to machine code.