To add to this; sharing is not always what you want; sometimes it's a
time/space trade-off and sometimes it's actually strictly worse than
not sharing.
For example:
f :: Integer - [Integer]
f x = take 1000 [x..]
sum :: [Integer] - Integer
sum = foldl' (+) 0
expensiveZero :: Integer
I'm new to Haskell and trying to get a better understanding of sharing
(and ultimately memoization). I've read SOE and various of the
tutorials, as well as browsing around the wiki and old mailing lists.
Most of the examples of memoization seem to revolve around Fibonacci,
and are based
Patrick Surry wrote:
I've seen other discussions that suggest that lists are always shared
while in scope (so the fibs trick works). But is that just a feature of
the standard compilers, or is it somewhere mandated in the Hakell spec
(I don't see anything obvious in the Haskell Report tho