A common practice in world C for comparing two fragments of C is to see which assembly they generate. I wanted to know what GHC code would generate in case of:
afmap :: Functor f => (a -> b -> c) -> f b -> a -> f c afmap fn fb a' = (fn a') <$> fb
and
afmap = flip . (((.).(.)) fmap ($))
So I tried:
$ ghc -S test.hs -o test.S
Which (unsurprisingly) gave a more or less unreadable code.
What is the correct way (if any) to evaluate how ghc optimizes the code?
The assembly is probably too low level. You will probably want to look at the Core Intermediate Optimization Language, GHC.
, GHC Haskell Core, Core STG, C - (.. ) LLVM ( ).
, Core - Haskell (.. , ). Core, , , .