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
add twiddles inside:
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:[EMAIL PROTECTED]]
| Sent: 01 March 2001 11:26
| To: [EMAIL PROTECTED]
| 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:[EMAIL PROTECTED]
| 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
__________________________________________________________________________
_______________________________________________
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell
_______________________________________________
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell