GHC Core, STG and Cmm views on Compiler explorer

I recently did some work on compiler explorer ( to add additional output panes for GHC Core, STG and Cmm. Similar to how you could have LLVM IR or Rust MIR outputs for those compilers.

Here is a link with them in action: Compiler Explorer

You find them in the assembly output pane under “Add new…”:


Thank you!

Would it be possible at all to get matching colors with the input and assembly output?

Also, I notice you have -dsuppress-all enabled by default. I would recommend to turn on -dno-suppress-type-signatures as they add minimal noise. Or maybe you should just let the user supress what they want. I noticed I am still able to manually adjust the suppression using the Compiler options... field.

Last question, is it possible to have both an optimized (-O2) and unoptimized (-O0) Core view open at the same time? Edit: I found a way to do it: you can click “clone compiler” and set different options for it and open a new core view for those options.


Note that the Haskell playground also has core and asm output: Haskell Playground


Without -dsupress-all there are some source location information in the debug output. But I think that parsing this and adding the colouring would be a massive chunk of work, and I’m sure the debug output format is not stable either. I will not try to do this.

I considered different options but (like -dno-typeable-binds as I have in the example). It is probably best to leave it for the user to choose. Maybe -dsuppress-all should be removed as well.


I agree, it is probably too much work to do this just for godbolt. But I think it would be great if GHC could provide a stable way to expose that information and other tools, perhaps HLS, could also use it.

I’ve been dreaming of a tool that shows how GHC optimizes code. It would start with the source file and show how it maps to the desugared core. Then, for each declaration you can click on it and you can step through how it evolves through compiler optimizations.


Cool!!! I wish I had such tool at university.
How to attach a library? E.g. I want to explore LinearTypes extension effect - GHC-9.2 support the extension but all functions like + are in linear-base library, which is not shipped with GHC.

…and now godbolt supports GHC 9.4 and 9.6 as well.