Chapter 9. GHC Internals and Code Generation

In the previous chapter, we learned to tweak options in GHC and Runtime System. In this chapter, we will dive into GHC's internal language, Core. We will learn to read Core and to spot possible problems in Core. Such problems arise when, for instance, the strictness analyzer left an argument lazy and boxed, while it would have been a lot more performant to make it strict and unboxed. We can basically just read such situations from Core, because strictness is explicit and unboxed arguments are always output with hashes.

Recall that the hash suffix is referred to as the magic hash in Haskell. Magic hashes mark primitive functions and types (those provided by GHC itself). We call these primops. In this ...

Get Haskell High Performance Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.