[Haskell-cafe] Re: Processing of large files
alexander at kogan.nnov.ru
Thu Nov 4 03:44:32 EST 2004
> Scott's solution forces (lookupFM a' x) to head normal form (or is it
> weak head normal form). This means that the value of type (Maybe v) is
> evaluated as much that it is known whether it is Nothing, Just _ or _|_
> (bottom). This is probably enough to evaluate the path from FiniteMap's
> tree root to x. However (lookupFM a' x) in head normal form can be still
> something like this:
> Just <unevaluated: 1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1>
> So we have to force the value at key 'x' also. My code uses maybe, which
> may obfuscate things a bit. Here's another version, which should be
> easier to understand:
> let a' = addToFM_C (+) a x 1 in
> case lookupFM a' x of
> Nothing -> a'
> Just v -> v `seq` a'
I have 2 questions about this:
1. This means seq function evaluates only 'top' of argument, so when I pass,
for example, list as argument, it will be evaluated only to [unevaluated,
unevaluated, ...]? Am I right?
2. If so, is there method to _completely_ evaluate expression?
Institute of Applied Physics
Russian Academy of Sciences
More information about the Haskell-Cafe