On Dec 21, 2007 2:38 PM, Jules Bean <<a href="mailto:firstname.lastname@example.org">email@example.com</a>> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">David Menendez wrote:<br>>> That's a reasonable thing to assume. It just happens that Haskell<br>> doesn't work that way. There's an asymmetry between constructing and<br>> pattern-matching, and it's one that many people have complained about.
<br><br></div>With GADTs turned on (-XGADTS in 6.8, -fglasgow-exts in 6.6) pattern<br>matchings will give rise to class contexts as you would naively expect.<br><br>Contexts on constructors aren't actualy haskell98, it is a bug that GHC
<br>6.6 accepts them without any extensions being activated. Or that's my<br>understanding, see <a href="http://hackage.haskell.org/trac/ghc/ticket/1901" target="_blank">http://hackage.haskell.org/trac/ghc/ticket/1901
</a><font color="#888888"></font></blockquote><div><br>I think I saw  and just mentally substituted . In fact, until just now I didn't know  was even possible. (Wasn't there some problem with class contexts in GADTs?)
<br><br> data SquareType a = (Num a) => SquareConstructor a<br> data (Num a) => SquareType a = SquareConstructor a<br><br>Okay, so pattern-matching in case  does guarantee Num a. In that case, the original code didn't work because it was trying to unify Int with an arbitrary instance of Num.
<br></div></div><br>-- <br>Dave Menendez <<a href="mailto:firstname.lastname@example.org">email@example.com</a>><br><<a href="http://www.eyrie.org/~zednenem/">http://www.eyrie.org/~zednenem/</a>>