« Return to Thread: Lazy in either argument?

Re: Lazy in either argument?

by Albert Y. C. Lai :: Rate this Message:

Reply to Author | View in Thread

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.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@...
http://www.haskell.org/mailman/listinfo/haskell-cafe

 « Return to Thread: Lazy in either argument?