If you want to understand how Haskell programs execute at a low level, it is probably best to study Core instead (-ddump-simpl
). After that point the code becomes really hard to read even for experts. The main reason is that GHC's stack and heap management gets hard-coded. As a result, low-level generated Haskell code is basically a giant mess of tiny procedures, doing complex pointer arithmetic before finishing with indirect jumps to unknown locations. The worst kind of spaghetti code.
To provide something of an actual answer - you could generate C by going over the LLVM backend:
ghc -ddump-llvm -ddump-to-file hello_world.hs
opt -O2 hello_world.dump-llvm | llc -O2 -march c -o hello_world.c
But the result will just illustrate the point. Even a trivial fib
function will take about 80 lines of code.
In case you are really interested in the gory details, I would recommend reading through this blog post by Edward Z. Yang. He basically walks through the whole compilation pipeline involved in translating a simple piece of Haskell code.