<div dir="ltr">Note though, it doesn't mean the same thing to say (Foo a, Bar a b) => ... as it does to say<div><br></div><div>Foo a => Bar a b => ...</div><div><br></div><div>The latter can use Foo a when working on Bar a b, but not Bar a b to discharge Foo a, which makes a difference when you have functional dependencies.</div><div><br></div><div>So in some sense the 'pattern requires/supplies' split is just that.</div><div><br></div><div><br></div><div><br></div><div>That said, Richard's other option</div><div><br></div><div>pattern Foo a => P :: Bar a => a</div><div><br></div><div>has the benefit that it looks a bit like the old datatype contexts (but here applied to the constructor/pattern).</div><div><br></div><div>If we expect the left hand side or the right hand side to be most often trivial then that may be worth considering.</div><div><br></div><div>You'd occasionally have things like</div><div><br></div><div>pattern (Num a, Eq a) => Foo :: a</div><div><br></div><div>for </div><div><br></div><div>pattern Foo = 8<br></div><div><br></div><div>but most of the time they'd wind up just looking like a GADT constructor.</div><div><br></div><div>-Edward</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Nov 9, 2014 at 10:02 PM, Richard Eisenberg <span dir="ltr"><<a href="mailto:eir@cis.upenn.edu" target="_blank">eir@cis.upenn.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
On Nov 9, 2014, at 2:11 PM, Simon Peyton Jones <<a href="mailto:simonpj@microsoft.com">simonpj@microsoft.com</a>> wrote:<br>
><br>
> * One other possibility would be two => thus<br>
>       pattern P :: (Eq b) => (Num a, Eq a) => ...blha...<br>
><br>
<br>
</span>I should note that I can say this in 7.8.3:<br>
<br>
foo :: Show a => Eq a => a -> String<br>
foo x = show x ++ show (x == x)<br>
<br>
Note that I've separated the two constraints with a =>, not a comma. This syntax does what you might expect. (I actually believe that this is an improvement over the conventional syntax, but that's a story for another day.) For better or worse, this trick does not work for GADT constructors (which is a weird incongruence with function type signatures), so adding the extra arrow does not really steal syntax from GADT pattern synonyms.<br>
<span class="HOEnZb"><font color="#888888"><br>
Richard<br>
</font></span><div class="HOEnZb"><div class="h5">_______________________________________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/ghc-devs" target="_blank">http://www.haskell.org/mailman/listinfo/ghc-devs</a><br>
</div></div></blockquote></div><br></div>