On 2008 Oct 19, at 11:25, 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)
For starters, "let" is lazy. "case" is strict to the extent that it
has to evaluate enough to decide if the result is Just or Nothing, but
that's useless if the code leading up to its application is lazy. I
don't know how lazy matchRegex is, if it is lazy enough then all that
gets evaluated by the case is just enough to know if the result is
Just or Nothing but not the value of "strs". (One obvious possibility
is that it determines that there *are* strings, but not what they
are.) Everything else is automatically lazy.
So, unless the caller forces the result of this function, you are very
likely to end up with a chain of partially evaluated matches that
don't get resolved until the result is printed.
--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED]
system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon university KF8NH
_______________________________________________
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell