Maybe this is old news, but I only just today realized that The Architecture of Open Source Applications has a chapter on the GHC compiler: https://aosabook.org/en/v2/ghc.html
This is really neat as it contains (among lots of other nice things) a summary of the optimization parts of GHC, which I’ve had a lot of trouble finding elsewhere!
It is scary to imagine how many hand-written test cases we would need to provide the same level of coverage that the type system provides.
