4 ms·
here is the output of main = print $ product [1..100] ghc-core-html --ghc-option=-ddump-simpl --ghc-option=-dsuppress-all fact.hs https://rawgit.com/
by platz 11y ago
here is the output of
main = print $ product [1..100]
ghc-core-html --ghc-option=-ddump-simpl --ghc-option=-dsuppress-all fact.hs
https://rawgit.com/jonschoning/c4ad2129aa7d258e65f9/raw/f8edf61aaba6a7a28dc60bb935738d648e53335c/fact.html https://rawgit.com/jonschoning/c4ad2129aa7d258e65f9/raw/f8ed...
you can see
main_go (plusInteger x_a3Sq main4) (timesInteger eta_B1 x_a3Sq);
where it compiles to a recursive loop with an accumulator
typicall the [1..100] gets compiled to (enumFromTo 1 100) and it can be desugared further..
so, yeah, foldmap compiles to foldr which may compile down further
- PeCaN 11y agofoldr usually gets deforested in GHC, so the intermediate list probably doesn't exist. GHC rewrites most of the common built-in functions to eliminate intermediate trees and lists. You can see a list https://downloads.haskell.org/~ghc/7.0.1/docs/html/users_guide/rewrite-rules.html https://downloads.haskell.org/~ghc/7.0.1/docs/html/users_gui... (section 7.14.4; ctrl-f "good producer").
- deleted 11y ago[deleted]