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 __________________________________________________________________________
Thu, 1 Mar 2001 12:25:33 +0100, S. Doaitse Swierstra <doaitse@cs.uu.nl> pisze:
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.
Toplevel ~ in let doesn't change anything. But nested ~'s do make a difference. When a variable of a pattern is evaluated, the whole pattern is matched. When you protect a subpattern by ~ deferring its matching and a variable from the subpattern is evaluated, again the whole subpattern is matched, unless its subsubpatterns are protected with their own ~'s etc. -- __("< Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZASTÊPCZA QRCZAK
On Fri, Mar 02, 2001 at 06:58:16PM +0000, Marcin 'Qrczak' Kowalczyk wrote:
Toplevel ~ in let doesn't change anything. But nested ~'s do make a difference. When a variable of a pattern is evaluated, the whole pattern is matched. When you protect a subpattern by ~ deferring its matching and a variable from the subpattern is evaluated, again the whole subpattern is matched, unless its subsubpatterns are protected with their own ~'s etc.
Is the behaviour of Hugs incorrect in this case? Best, Dylan Thurston
participants (3)
-
Dylan Thurston -
qrczak@knm.org.pl -
S. Doaitse Swierstra