<br><br><div class="gmail_quote">On Thu, Jul 16, 2009 at 12:40 PM, Andrew Coppin <span dir="ltr"><<a href="mailto:andrewcoppin@btinternet.com">andrewcoppin@btinternet.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">Robert Greayer wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
f0 _ = (foo True, foo 'x') where foo = id<br>
<br>
is well-typed.<br>
<br>
</blockquote>
<br></div>
Really? That actually works? How interesting... This suggests to me that where-clauses also do strange things to the type system.</blockquote><div><br>You could think of it that way. You mentioned GADTs in your OP. Well, it turns out GADTs often do not play nicely with where/let and it happens to all be related. As I understand it, functions bind their parameters monomorphically and let/where bind things polymorphically. And then we have the misfeature known as the monomorphism restriction which adds special cases.<br>
<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im"><br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
whereas<br>
<br>
f1 foo = (foo True, foo 'x')<br>
<br>
requires 'foo' to be polymorphic in its first argument. This does<br>
require a higher rank type, which can't be inferred:<br>
<br>
You could type f1 as<br>
f1 :: (forall a . a -> a) -> (Bool, Char)<br>
<br>
and apply it to 'id'.<br>
<br>
Or you could type it as something like:<br>
f1 :: (forall a . a -> ()) -> ((),())<br>
<br>
and apply it to 'const ()'<br>
</blockquote>
<br></div>
...all of which is beyond Haskell-98, which is what I am limiting myself to at present.<br>
<br>
(Actually, even that is a lie. I don't have type-classes yet...)</blockquote><div><br>Congrats on the type inference engine you're writing. It's on my list of things to do, and I was even reading up on TaPL a month or two back, but I put it down and haven't picked it up again yet. I think writing one would help flush out my understand of all this stuff.<br>
<br>Jason<br></div></div><br>