[Haskell-cafe] Re: (Chaos) [An interesting toy]
Simon Peyton-Jones
simonpj at microsoft.com
Mon May 7 06:28:37 EDT 2007
| Presumably changing it to resultant = foldl' (+) wouldn't help much either?
I think not.
| Seems to me there's always a tradeoff to be made between CPU time, RAM
| usage, and code size - if not other factors too. :-S But Haskell seems
| to be fairly unique in that (it looks like) it's possible to transform
| the code quite aggressively without too much difficulty. You wouldn't
| ever want to write source code for six different versions of sum, but if
| a compiler can do it automatically that's another matter. ;-)
|
| I guess I was assuming that a function like sum is "simple enough" to
| get inlined at the call site - and hence possibly optimised at that
| site. Apparently not.
There is no reason in principle why not. It's just that GHC doesn't do it at the moment.
| By the way, is there some way of discovering what
| GHC has "really" done with your code, rather than what you "think" it's
| done?
Yes: -ddump-simpl.
Simon
More information about the Haskell-Cafe
mailing list