3 ms·
Sure, but the order of evaluation do change something. For instance, infinite lists won't ever terminate, but taking the first 42 elements of an infinite list
by loup-vaillant 15y ago
Sure, but the order of evaluation do change something. For instance, infinite lists won't ever terminate, but taking the first 42 elements of an infinite list will terminate in Haskell, and not in ML. If you want to fuse the whole thing, it won't change the Haskell program, but it may change the ML one, by making it terminate an return the correct result!
That's not an optimization any more, that's a language feature.
- eru 15y agoYes. Though the situation is only that rosy in Haskell under some circumstances. It's easy to get space leaks that make your program use O(run-time) memory, if you are not careful with the laziness.
- loup-vaillant 15y agoAgreed. My only point is that automatic fusion (stream, shortcut, and even inlining in general) "works" more often in a pure and lazy setting.