<div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Well I'll go to 'foot of our stairs!<br></div><div dir="ltr"><div><br></div><div>> <span style="color:rgb(0,0,0);font-family:monospace,monospace;font-size:1em;white-space:pre-wrap">[Erik] the above feels very similar to writing </span><span style="color:rgb(0,0,0);font-family:monospace,monospace;font-size:1em;white-space:pre-wrap">something like:</span></div><pre style="white-space:pre-wrap;color:rgb(0,0,0)">> add :: _ => a -> b -> _
> add x y = x + y
>
> But that doesn't type check, since the types `a` and `b` are not the same,
> but `+` needs them to be.</pre><div>Replying to both Erik's and Tom's replies. I'm afraid Alexis' went completely over my head.</div><div><br></div><div>As I mentioned, the `PatternSignatures` part of `ScopedTypeVariables` has been around a long time. So long that it's in Hugs 2006. The same? Not quite. If I try Tom's O.P.</div><div><br></div><div> add (x :: aa) (y :: b) = x + y</div><div><br></div><div>Hugs complains 'Type annotation uses distinct variables aa and b where a single variable was inferred'.</div><div><br></div><div>So the short answer is: if that's how your intuitions go, use Hugs.</div><div><br></div><div>My explanation was going to be (this now only applies for GHC): just as using `x, y` as the dummy arguments to `add` doesn't come with any guarantees they're distinct values; so using `aa, b` as the dummy variables doesn't come with any guarantees they're distinct types.</div><div><br></div><div>Specifying distinct tyvars in a stand-alone signature is different: you're giving the most general type to which `add` must conform. And using distinct tyvars means `add` must cope with those being distinct types. (Which it's equation doesn't.) BTW GHC accepts:</div><div><br></div><div> add (x :: aa) (y :: b) = (x + y :: aa) :: b</div><div><br></div><div>which shows how happy it is to use distinct tyvars for the same type.</div><div><br></div><div>AntC</div><div class="gmail_quote"><div><br></div><div> </div></div></div>
</div></div>