Haskell programmer since 2012; GHC contributor since 2018. I’m interested in language design, programming language theory, and compiler engineering.
Haskell is an expressive language with many features. On one hand, it makes Haskell convenient, equipping the programmer with a rich arsenal of tools to get the job done and write high quality software. On the other hand, developing a thorough understanding of these tools, of all the language features, takes time, effort, and experience.
One way to build an intuition for a language feature is to use it. Practice makes perfect, and by trial and error you can discover the ins and outs of using certain parts of the language. However, the knowledge acquired this way may be superficial, and the mental model will only be as good as it was needed for the tasks at hand.
Deeper insight comes from a different perspective: you need to decompose a concept into its basic constituents. For example, what are multi-argument functions? In a curried language, we know that (a b c -> …) is much the same as (a -> b -> c -> …). Thus we have reduced the concept of a multi-argument function into a simpler concept of a single-argument function.
For a more involved example: what is do-notation? To grasp it, you need to think how it is desugared into >>= and >> (and also <*> with -XApplicativeDo).
What about infix operators, if-then-else expressions, list comprehensions, type classes, type families, GADTs? How much Haskell is essential, and how much is sugar on top?
In this talk, my first goal is to get you acquainted with GHC’s Core (System FC): a small, elegant language, into which every Haskell program is desugared during compilation; and my second goal is to demonstrate how the menagerie of Haskell features can be expressed using the few constructs of Core.
In every-day programming, reading compiler-generated Core can be useful when you are investigating the performance of a particular piece of code. But more importantly, I hope that seeing how Haskell features are translated into Core can help you develop a deeper understanding of these features.