# strictness question

S. Doaitse Swierstra doaitse@cs.uu.nl
Fri, 2 Mar 2001 21:08:45 +0100

```Thanks for the prompt reply. Hugs apparently is more lazy and
performs all the matching lazily, and that really makes a difference
in my case.

Doaitse

At 8:11 AM -0800 3/2/01, Simon Peyton-Jones wrote:
>Strange.  You don't supply a complete program, so it's hard to
>test.
>
>Nevertheless, the Haskell Report (Sect 3.12) specifies that
>a let adds a single twiddle.  Thus
>
>	let (x, (y,z)) = e in b
>
>means
>
>	let x = case e of (x,(y,z)) -> x
>	     y = case e of (x,(y,z)) -> y
>	     z = case e of (x,(y,z)) -> z
>	in b
>
>And that is what GHC implements.  You get something different if you
>
>	let (x, ~(y,z)) = e in b
>
>means
>	let x = case e of (x,_) -> x
>	     y = case e of (_,(y,_)) -> y
>	etc
>
>Adding more twiddles means less eager matching.  I don't know whether
>Hugs implements this.
>
>Simon
>
>| -----Original Message-----
>| From: S. Doaitse Swierstra [mailto:doaitse@cs.uu.nl]
>| Sent: 01 March 2001 11:26
>| Subject: strictness question
>|
>|
>| I ran into a difference between GHC and Hugs. The following code:
>|
>| f  (P p) ~(P q)   = P (\ k -> \inp -> let (((pv, (qv, r)), m), st) =
>| p (q k) inp
>|                                        in  (((pv qv  , r ), m), st))
>|
>| runs fine with Hugs but blows up with GHC, whereas:
>|
>| f  (P p) ~(P q)   = P (\ k -> \inp -> let ~(~(~(pv, ~(qv, r)), m),
>| st) = p (q k) inp
>|                                        in  (((pv qv  , r ), m), st))
>|
>| runs fine with GHC too.
>|
>|  From the Haskell manual I understand that pattern matching
>| in "let"'s
>| should be done lazily, so the addition of a collection of ~'s should
>| not make a difference. Am I right with  this interpretation?
>|
>| A possible source of this problem may be origination from the smarter
>| GHC optimiser, but in that case the optimiser is not doing its work
>| well.
>|
>|     Doaitse Swierstra
>|
>|
>|
>|
>| --
>| ______________________________________________________________
>| ____________
>| S. Doaitse Swierstra, Department of Computer Science, Utrecht
>| University
>|                        P.O.Box 80.089, 3508 TB UTRECHT,   the
>| Netherlands
>|                        Mail:  mailto:doaitse@cs.uu.nl
>|                        WWW:   http://www.cs.uu.nl/
>|                        PGP Public Key:
>http://www.cs.uu.nl/people/doaitse/
>                        tel:   +31 (30) 253 3962, fax: +31 (30) 2513791
>__________________________________________________________________________
>
>_______________________________________________

--
__________________________________________________________________________
S. Doaitse Swierstra, Department of Computer Science, Utrecht University
P.O.Box 80.089, 3508 TB UTRECHT,   the Netherlands
Mail:  mailto:doaitse@cs.uu.nl
WWW:   http://www.cs.uu.nl/
PGP Public Key: http://www.cs.uu.nl/people/doaitse/
tel:   +31 (30) 253 3962, fax: +31 (30) 2513791
__________________________________________________________________________

```