I'll have to agree with that. But then I would also say that I had to make some assumptions, right? :)
I think GHCi is helpful in this situation, however. It clearly distinguishes between leaky and non-leaky code. This leak is a product of "just doing what the coder says" (go to "Data.Monoid.sum" and do what it says there with such and such...). I'm assuming that, for this code, GHCi is bug-free.
I think
sum (replicate n 0)
is as dangerous as
foldl (+) 0 (replicate n 0)
or
foldr (+) 0 (replicate n 0)
. `sum (replicate n 0)` may be the right thing to do in some cases unknown to me.
There is `{-# LANGUAGE Strict #-}`, as you mention, and BangPatterns for strict arguments. But I would assume, those are used only by coders already familiar with haskell and its leaky pitfalls.
I think GHCi is helpful in this situation, however. It clearly distinguishes between leaky and non-leaky code. This leak is a product of "just doing what the coder says" (go to "Data.Monoid.sum" and do what it says there with such and such...). I'm assuming that, for this code, GHCi is bug-free.
I think
is as dangerous as or . `sum (replicate n 0)` may be the right thing to do in some cases unknown to me.There is `{-# LANGUAGE Strict #-}`, as you mention, and BangPatterns for strict arguments. But I would assume, those are used only by coders already familiar with haskell and its leaky pitfalls.