[Haskell-cafe] Lazy in either argument?
Albert Y. C. Lai
trebla at vex.net
Thu Jul 26 17:18:47 EDT 2007
Dan Weston wrote:
> 1) Commenting out the type annotation f :: Bool makes the program hang
Turning on code optimizations (e.g., ghc -O) helps. I don't know why.
> 2) If I replace f = f by f = undefined, I get an annoying print of
> "LazyOr: Prelude.undefined" before it returns the correct value.
The error message is a manifestation of an unhandled exception. Look for
exception handling tools in Control.Exception and use one to your
liking. You should do this to be very general anyway, since _|_ can be
infinite loops or exceptions.
Beware that parallelizing the two arguments (making them compete) is
still different from laziness in either argument. Laziness does not only
include waiting less, but also includes leaving thunks untouched.
Competition leads to waiting less certainly, but it also forces both
thunks. A user may or may not want this.
That said, parallel disjunction is interesting in its own right, mainly
because it restores the symmetry found in logical disjunction that has
been lost in short-circuiting. There was a paper using it for
programming language semantics, but I have long forgotten it.
More information about the Haskell-Cafe
mailing list