<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On 2008 Nov 12, at 10:53, Jeff Polakow wrote:</div><blockquote type="cite"><tt><font size="2">Now, if we switch to an analogous, though slightly more complicated type, GHC's type checker accepts the following code:</font></tt> <br> <br><tt><font size="2">&nbsp; &nbsp; bar :: (forall b. b -> String, Int)</font></tt> <br><tt><font size="2">&nbsp; &nbsp; bar = (const "hi", 0)</font></tt> <br><tt><font size="2">&nbsp; &nbsp; foo :: forall b.(b -> String, Int)</font></tt> <br><tt><font size="2">&nbsp; &nbsp; foo = (const "hi", 0)</font></tt> <br> <br><tt><font size="2">however GHC's type checker rejects the following code (I now think this is correct):</font></tt> <br> <br><tt><font size="2">&nbsp; &nbsp; bar :: (forall b. b -> String, Int)</font></tt> <br><tt><font size="2">&nbsp; &nbsp; bar = (const "hi", 0)</font></tt> <br><tt><font size="2">&nbsp; &nbsp; foo :: forall b.(b -> String, Int)</font></tt> <br><tt><font size="2">&nbsp; &nbsp; foo = bar</font></tt> <br> <br><tt><font size="2">with the error :</font></tt> <br> <br><tt><font size="2">&nbsp; &nbsp; Couldn't match expected type `b -> String'</font></tt> <br><tt><font size="2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;against inferred type `forall b1. b1 -> String'</font></tt> <br> <br><tt><font size="2">and yet GHC accepts the following code: </font></tt> <br> <br><tt><font size="2">&nbsp; &nbsp; bar :: (forall b. b -> String, Int)</font></tt> <br><tt><font size="2">&nbsp; &nbsp; bar = (const "hi", 0)</font></tt> <br><tt><font size="2">&nbsp; &nbsp; foo :: forall b.(b -> String, Int)</font></tt> <br><tt><font size="2">&nbsp; &nbsp; foo = (fst bar, snd bar)</font></tt> <br> <br><tt><font size="2">which is just the eta-expansion of the previous code.</font></tt> <br> <br><tt><font size="2">This behavior seems inconsistent to me. I don't see any reason why the (f = b) should be different than (foo = bar). In fact, thinking more carefully about the types, I think that (f = b) should not type and the eta expansion (f = \x -> b x) should be required.</font></tt> <br></blockquote></div><div><br></div><div>Seems right to me: &nbsp;symbolically it may be an eta-expansion, but practically GHC's tuples are actually types, so the latter is a new tuple with a different type from the former. &nbsp;(GHC's handling of tuples is often infelicitous.)</div><br><div apple-content-edited="true"> <span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div><font class="Apple-style-span" face="Monaco"><span class="Apple-style-span" style="font-family: Monaco; "><span class="Apple-style-span" style="font-family: Monaco; ">--&nbsp;</span></span></font></div><div><font class="Apple-style-span" face="Monaco"><span class="Apple-style-span" style="font-family: Monaco; "><span class="Apple-style-span" style="font-family: Monaco; ">brandon s. allbery [solaris,freebsd,perl,pugs,haskell] <a href="mailto:allbery@kf8nh.com">allbery@kf8nh.com</a></span></span></font></div><div><font class="Apple-style-span" face="Monaco"><span class="Apple-style-span" style="font-family: Monaco; "><span class="Apple-style-span" style="font-family: Monaco; ">system administrator [openafs,heimdal,too many hats] <a href="mailto:allbery@ece.cmu.edu">allbery@ece.cmu.edu</a></span></span></font></div><div><font class="Apple-style-span" face="Monaco"><span class="Apple-style-span" style="font-family: Monaco; "><span class="Apple-style-span" style="font-family: Monaco; ">electrical and computer engineering, carnegie mellon university &nbsp; &nbsp;KF8NH</span></span></font></div><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><br class="Apple-interchange-newline"></span></span></span></div></span> </div><br></body></html>