learning to love laziness

Derek Elkins ddarius at hotpop.com
Fri Sep 26 02:30:30 EDT 2003


On Thu, 25 Sep 2003 12:59:37 -0700
Mark Tullsen <tullsen at galois.com> wrote:

> Haskell has lazy/lifted products and not true products. 

Aren't lazy products true products?  What makes something a product is:
fst (x,y) = x
snd (x,y) = y 
for all x and y.  This holds with lazy products but not eager ones 
fst (3,_|_) = _|_ /= 3

I'd think the problem is that Haskell isn't consistently lazy (for good
reason!).  Haskell has eager coproducts (case analysis).  If you didn't
use pattern matching (or used lazy pattern matching), then this problem
wouldn't come up.  Of course, lazy coproducts (pattern matching) is
somewhat uninteresting (f ~True = 1;f ~False = 2; f False == 1)

> Maybe from seeing this, it's clearer why laws such as
>    x = (fst x,snd x)
> do not hold.  Neither does the following law hold
>     (uncurry . curry) f = f
> which is unfortunate (for a language named after Haskell *Curry*).
> To see why it doesn't hold, compare t1 and t2 in this program:
>    f (_,_) = 1
>    t1 = f undefined
>    t2 = (uncurry . curry) f undefined



More information about the Haskell mailing list