4 ms·
out of interest, can somebody check how GHC compiles the factorial function as defined in the blogpost?
by LeanderK 10y ago
out of interest, can somebody check how GHC compiles the factorial function as defined in the blogpost?
- grenoire 10y agoNot GHC, but GCC 6.3 with -O2 is https://godbolt.org/g/ATkIr1 https://godbolt.org/g/ATkIr1 for reference.
- rnhmjoj 10y agohttps://gist.github.com/b097fded87a2b16863947acd3a975b2a https://gist.github.com/b097fded87a2b16863947acd3a975b2a This is code produced by GHC 8.0.2 for the program module Test where factorial :: Int -> Int factorial n = product [1 .. n] The module thing is necessary to produce the object file without a "main" function.