|Version 7 (modified by benl, 5 years ago)|
These pages give an overview of how the compiler fits together, and record notes on the implementation.
Intermediate Languages (IRs)
The compiler uses four intermediate languages.
- Source Language
A representation of the source program that preserves all the syntactic structure of the original.
- Desugared Language
We currently desugar the source language before extracting type constraints. This makes the compiler easier to change and maintain, at the cost of not being able to produce type error messages as nice as the ones in GHC (which does type inference directly on the source). We extract type constraints from the desugared program, then solve them, which gives us enough information to convert the program to the core language.
- Core Language
A System-F style core language, complete with type abstraction and application. Most optimizations are performed in the core language.
- Sea Language
An abstract-C like language. Serves as a target for the Core -> Sea transform. It'd probably be better to replace this with a third-party back-end language like C-- or LLVM. The Sea program is pretty printed into ANSI C code, which is compiled into object code by GCC.
- Source -> Desugared IR
- Type Constraint Slurper
- Type Constraint Solver
- Desugared IR -> Core IR
- Core Transforms
- Core IR -> Sea IR
- Sea Transforms
- Runtime System