[Haskell-cafe] Optimizing unamb by determining the "state" of a
bugfact at gmail.com
Mon Apr 20 16:54:55 EDT 2009
f `unamb` g just needs f or g to be in weak head normal form I think. This
should be much easier to test for I guess.
I always confuse weak head normal form with reduced head normal form, but
the documentation of GHC does not help here:
-- | Reduces its argument to weak head normal form.rwhnf :: Strategy a
rwhnf x = x `seq` ()
but the documentation of seq says
*seq* :: a -> b -> bSource
its first argument to head normal form, and then returns its second
argument as the result.
*rnf* :: Strategy
its argument to (head) normal form.
So from the documentation rnf should be like seq, but it is not, rnf
is a "deep seq".
I find this very confusing. Is the documentation of seq wrong (should
be weak head normal form)?
Anyway, so I guess we would actually need a function:
iswhnf :: a -> IO Bool
But since the value of this iswhnf function depends on when it is called, I
feel it has to be in the IO monad; actually multiple threads evaluating it
have nothing to do with it?
On Mon, Apr 20, 2009 at 10:05 PM, Jake McArthur <jake.mcarthur at gmail.com>wrote:
> Christopher Lane Hinson wrote:
>> What we'd like to avoid is duplicate verification that a thunk is hnf. Do
>> we have evidence that this verification ever actually consumes a lot of
> I think the OP is trying to avoid spawning unnecessary threads at the cost
> of duplicate checks for HNF.
> - Jake
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe