Yet another weakly defined bug report

Ketil Z. Malde ketil@ii.uib.no
17 Feb 2003 14:01:16 +0100


Dean Herington <heringto@cs.unc.edu> writes:

> Yes, getting the right amount of strictness--and in the right places--can be
> tricky. 

Tell me about it!

> You should do the counting strictly:
> 
>         Just n -> case n+1 of n1 -> addToFM f w n1

Thanks for the tip.  Just performing this change didn't perceptibly
change anything, though.  It seems to be working all right now, but to
my amazement, it may have been upgrading to 5.04.2 that did it?!  (I
had a lot of heapCensus trouble)  Is this at all possible?

> Right, except that, as Simon M. mentioned, the file is opened so that any opening
> exceptions are triggered.

Yeah.  I keep forgetting the IO monad is imperative.

> Perhaps.  You're only demanding the head of the list.  Conceivably, the FM logic
> might be able to determine the lowest key/element pair without evaluating the
> entire map.

> I find the above approach a bit risky, as you are closing the file after having
> only shallowly demanded the result of addHist.  My earlier suggestion, return $!
> addHist fm x, makes exactly the same shallow demand, but if that demand is
> insufficient, loses performance but not correctness.

..but then I could equally well use readFile, couldn't I?

Anyway, thanks for all the suggestions, all of you.

-kzm
-- 
If I haven't seen further, it is by standing in the footprints of giants