Erlang and Haskell are childhood friends who grew up together. Throughout the years, they have learnt a lot from each other. And just because they have become adults does not mean the learning stops.
GHC translates all of Haskell into a tiny but super-expressive intermediate language called Core, does a lot of optimisations on Core, and then generates executable code. Core is statically typed, making GHC one of the very few production compilers that is statically typed all the way through to code generation. It pulls off this trick by drawing directly on System F, a mathematical calculus from type theory. Functional programming is amazing: serious theory leads directly to beautiful implementations.
In this talk I’ll take you on a journey into Core and its design choices. I’ll sketch Core’s type system, and the optimisations that GHC implements in Core, including let-floating, strictness analysis, specialisation, inlining, and the case-of-case transformation.
Haskell and Erlang are both functional languages, albeit with significant differences (strict vs lazy, untyped vs typed). I hope that the talk may lead to dialogue about how these similarities and differences show up in a compiler.