Friedrich wrote:
Ok to be more concrete is the laziness "hidden" here?
check_line line sum count =
let match = matchRegex regexp line
in case match of
Just strs -> (sum + read (head strs) :: Integer, count + 1)
Nothing -> (sum, count)
Probably. I would guess that "sum" and "count" are not being forced
(i.e. evaluated) until the end of the computation, so instead of
computing the result of "sum + read (head strs)" your program is just
creating a thunk. Because this is in a loop, you wind up with a chain
of thunks.
Try putting turning the "Just" line into something like
Just strs -> (seq sum $ sum + read (head strs) :: Integer, seq count
$ count + 1)
That would be my guess. But I could be wrong.
Paul.
_______________________________________________
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell