
On Mon, Apr 20, 2009 at 2:54 PM, Peter Verswyvelen
I find this very confusing. Is the documentation of seq wrong (should be weak head normal form)?
Yes. Weak head normal form is really the only *essential* one. The popular runtimes do not know how to reduce under a lambda, so they can't reduce something to hnf.
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?
This is an impure function for a few reasons. I.e. not only does it give different answers at different times (depending on evaluation order), but it is not pure in the domain theory; i.e. (\x. x) 42 = 42, but iswhnf gives different answers for these. So yes, definitely in IO, as a runtime extension (I wouldn't even expect this function to be implementable on all runtimes). Luke