
On Thu, Nov 04, 2004 at 10:37:25AM +0300, Alexander Kogan wrote:
Hi!
How about this?
let a' = addToFM_C (+) a x 1 in maybe () (`seq` ()) (lookupFM a' x) `seq` a'
It worked for me.
Thank you. It works for me too, but I don't understand why and how ;-)) Could you explain?
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