<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"><base href="x-msg://542/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>I'm sure I've used the feature that you're proposing to remove, but I'll adapt. To be clear, the change means no loss of expressiveness, just that I'll sometimes have to use a helper type family (closed or open), right?</div><div><br></div><div>If I'm right there, then no complaints from me.</div><div><br></div><div>Richard</div><br><div><div>On Jun 24, 2014, at 4:07 AM, Simon Peyton Jones <<a href="mailto:simonpj@microsoft.com">simonpj@microsoft.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div lang="EN-GB" link="blue" vlink="purple" style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div class="WordSection1" style="page: WordSection1; "><div style="margin: 0cm 0cm 0.0001pt 36pt; font-size: 12pt; font-family: 'Times New Roman', serif; ">I’m not sure when this ”feature” was added, but I’m pretty sure that my original implementation of associated types was exactly what you describe in the solution. Or did I miss anything?<o:p></o:p></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: Calibri, sans-serif; color: rgb(31, 73, 125); "> </span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">I think you are right. I think I added the new stuff in a fit of enthusiasm one day, a fit that I am now regretting!   But I’m just checking that no one has meanwhile become addicted to it.<o:p></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: Calibri, sans-serif; color: rgb(31, 73, 125); "><br>Simon<o:p></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: Calibri, sans-serif; color: rgb(31, 73, 125); "> </span></div><div style="border-style: none none none solid; border-left-width: 1.5pt; border-left-color: blue; padding: 0cm 0cm 0cm 4pt; "><div><div style="border-style: solid none none; border-top-width: 1pt; border-top-color: rgb(225, 225, 225); padding: 3pt 0cm 0cm; "><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><b><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif; ">From:</span></b><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif; "><span class="Apple-converted-space"> </span>Manuel Chakravarty [mailto:mchakravarty@<a href="http://me.com" style="color: purple; text-decoration: underline; ">me.com</a>]<span class="Apple-converted-space"> </span><br><b>Sent:</b><span class="Apple-converted-space"> </span>24 June 2014 08:54<br><b>To:</b><span class="Apple-converted-space"> </span>Simon Peyton Jones<br><b>Cc:</b><span class="Apple-converted-space"> </span>GHC List;<span class="Apple-converted-space"> </span><a href="mailto:ghc-devs@haskell.org" style="color: purple; text-decoration: underline; ">ghc-devs@haskell.org</a><br><b>Subject:</b><span class="Apple-converted-space"> </span>Re: Associated type instances<o:p></o:p></span></div></div></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><o:p> </o:p></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; ">Simon,<o:p></o:p></div><div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><o:p> </o:p></div></div><div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; ">I’m not sure when this ”feature” was added, but I’m pretty sure that my original implementation of associated types was exactly what you describe in the solution. Or did I miss anything?<o:p></o:p></div></div><div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><o:p> </o:p></div></div><div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; ">Manuel<o:p></o:p></div></div><div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><o:p> </o:p></div><div><div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; ">Simon Peyton Jones <<a href="mailto:simonpj@microsoft.com" style="color: purple; text-decoration: underline; ">simonpj@microsoft.com</a>>:<o:p></o:p></div></div><blockquote style="margin-top: 5pt; margin-bottom: 5pt; "><p class="MsoNormal" style="margin: 0cm 0cm 6pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: Calibri, sans-serif; ">Friends</span><span style="font-size: 11pt; font-family: Calibri, sans-serif; "><o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 6pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: Calibri, sans-serif; ">I want to make withdraw (or, rather, simplify) a little-known feature in GHC, but before I do so I want to check that no one is going to have a heart attack.</span><span style="font-size: 11pt; font-family: Calibri, sans-serif; "><o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 6pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: Calibri, sans-serif; ">Relevant bits of the user manual:<span class="apple-converted-space"> </span><a href="http://www.haskell.org/ghc/docs/latest/html/users_guide/type-families.html#assoc-decl" style="color: purple; text-decoration: underline; "><span style="color: rgb(149, 79, 114); ">http://www.haskell.org/ghc/docs/latest/html/users_guide/type-families.html#assoc-decl</span></a></span><span style="font-size: 11pt; font-family: Calibri, sans-serif; "><o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 6pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: Calibri, sans-serif; ">All of this arose when thinking about fixing Trac #9063.</span><span style="font-size: 11pt; font-family: Calibri, sans-serif; "><o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 6pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: Calibri, sans-serif; ">I believe that this change will affect essentially nobody, and I propose to implement forthwith in HEAD (and hence 7.10). </span><span style="font-size: 11pt; font-family: Calibri, sans-serif; "><o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 6pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: Calibri, sans-serif; ">Does anyone object?</span><span style="font-size: 11pt; font-family: Calibri, sans-serif; "><o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 6pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: Calibri, sans-serif; ">Thanks</span><span style="font-size: 11pt; font-family: Calibri, sans-serif; "><o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 6pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: Calibri, sans-serif; ">Simon</span><span style="font-size: 11pt; font-family: Calibri, sans-serif; "><o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 6pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: Calibri, sans-serif; "> </span><span style="font-size: 11pt; font-family: Calibri, sans-serif; "><o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 6pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><b><span style="font-size: 16pt; font-family: Calibri, sans-serif; ">The issue</span></b><span style="font-size: 11pt; font-family: Calibri, sans-serif; "><o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 6pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: Calibri, sans-serif; ">Consider this:</span><span style="font-size: 11pt; font-family: Calibri, sans-serif; "><o:p></o:p></span></p><div style="margin-left: 36pt; "><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: 'Courier New'; ">class C a where<o:p></o:p></span></div></div><div style="margin-left: 36pt; "><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: 'Courier New'; ">   type T a b :: *<o:p></o:p></span></div></div><div style="margin-left: 36pt; "><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: 'Courier New'; "> <o:p></o:p></span></div></div><div style="margin-left: 36pt; "><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: 'Courier New'; ">instance C [x] where<o:p></o:p></span></div></div><div style="margin-left: 36pt; "><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: 'Courier New'; ">   type T [x] b = x -> b<o:p></o:p></span></div></div><p class="MsoNormal" style="margin: 0cm 0cm 6pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: Calibri, sans-serif; ">That is just what you’d expect.  But currently this is allowed too:</span><span style="font-size: 11pt; font-family: Calibri, sans-serif; "><o:p></o:p></span></p><div style="margin-left: 36pt; "><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: 'Courier New'; ">instance C [x] where<o:p></o:p></span></div></div><div style="margin-left: 36pt; "><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: 'Courier New'; ">   type T [x] Int = x -> Int<o:p></o:p></span></div></div><div style="margin-left: 36pt; "><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: 'Courier New'; ">   type T [x] Bool = Bool -> x<o:p></o:p></span></div></div><p class="MsoNormal" style="margin: 0cm 0cm 6pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: Calibri, sans-serif; ">That is,<span class="apple-converted-space"> </span><b>GHC 7.8 allows many associated type instances</b>, provided they don’t overlap.  But, oddly you can’t further instantiate the instance pattern. This would make just as much sense, but isn’t allowed:</span><span style="font-size: 11pt; font-family: Calibri, sans-serif; "><o:p></o:p></span></p><div style="margin-left: 36pt; "><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: 'Courier New'; ">instance C [x] where<o:p></o:p></span></div></div><div style="margin-left: 36pt; "><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: 'Courier New'; ">   type T [Int] b = b -> Int<o:p></o:p></span></div></div><div style="margin-left: 36pt; "><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: 'Courier New'; ">   type T [Bool] b = Bool -> b<o:p></o:p></span></div></div><p class="MsoNormal" style="margin: 0cm 0cm 6pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: Calibri, sans-serif; ">Moreover, as the user manual says, for an open kind like *, none of this really makes sense. It really only makes sense for a closed kind. Something like</span><span style="font-size: 11pt; font-family: Calibri, sans-serif; "><o:p></o:p></span></p><div style="margin-left: 36pt; "><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: 'Courier New'; ">class D a where<o:p></o:p></span></div></div><div style="margin-left: 36pt; "><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: 'Courier New'; ">   type S (b :: Bool) a :: *<o:p></o:p></span></div></div><p class="MsoNormal" style="margin: 0cm 0cm 6pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: Calibri, sans-serif; ">Now<span class="apple-converted-space"> </span><i>this</i><span class="apple-converted-space"> </span>would make some kind of sense:</span><span style="font-size: 11pt; font-family: Calibri, sans-serif; "><o:p></o:p></span></p><div style="margin-left: 36pt; "><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: 'Courier New'; ">instance D [x] where<o:p></o:p></span></div></div><div style="margin-left: 36pt; "><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: 'Courier New'; ">   type S True [x] = x -> x<o:p></o:p></span></div></div><div style="margin-left: 36pt; "><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: 'Courier New'; ">   type S False [x] = x<o:p></o:p></span></div></div><p class="MsoNormal" style="margin: 0cm 0cm 6pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: Calibri, sans-serif; ">But for closed kinds, you really want a<span class="apple-converted-space"> </span><i>closed</i><span class="apple-converted-space"> </span>type family.  So this would be better:</span><span style="font-size: 11pt; font-family: Calibri, sans-serif; "><o:p></o:p></span></p><div style="margin-left: 36pt; "><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: 'Courier New'; ">instance D [x] where<o:p></o:p></span></div></div><div style="margin-left: 36pt; "><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: 'Courier New'; ">   type S b [x] = SHelp x b<o:p></o:p></span></div></div><div style="margin-left: 36pt; "><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: 'Courier New'; "> <o:p></o:p></span></div></div><div style="margin-left: 36pt; "><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: 'Courier New'; ">type family SHelp x b where<o:p></o:p></span></div></div><div style="margin-left: 36pt; "><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: 'Courier New'; ">  SHelp x True = x -> x<o:p></o:p></span></div></div><div style="margin-left: 36pt; "><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: 'Courier New'; ">  SHelp x False = x<o:p></o:p></span></div></div><div style="margin-left: 36pt; "><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: 'Courier New'; "> <o:p></o:p></span></div></div><p class="MsoNormal" style="margin: 0cm 0cm 6pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: Calibri, sans-serif; ">So yes, you do have to declare a named helper type, but you get something much more perspicuous and explicit in exchange.</span><span style="font-size: 11pt; font-family: Calibri, sans-serif; "><o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 6pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: Calibri, sans-serif; ">All of this also applies to the default declaration(s) which you can supply for an associated type (see 7.7.3.2 in the link above), only it’s a bit more complicated and indirect.</span><span style="font-size: 11pt; font-family: Calibri, sans-serif; "><o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 6pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><b><span style="font-size: 16pt; font-family: Calibri, sans-serif; ">My solution</span></b><span style="font-size: 11pt; font-family: Calibri, sans-serif; "><o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 6pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: Calibri, sans-serif; ">I propose to simplify substantially, as follows:</span><span style="font-size: 11pt; font-family: Calibri, sans-serif; "><o:p></o:p></span></p><p class="MsoListParagraph" style="margin-right: 0cm; margin-left: 36pt; font-size: 12pt; font-family: 'Times New Roman', serif; margin-bottom: 6pt; text-indent: -18pt; "><span style="font-family: Symbol; ">·</span><span style="font-size: 7pt; ">        <span class="apple-converted-space"> </span></span><span style="font-family: Calibri, sans-serif; ">The “shared arguments” of an associated type are the argument positions that mention a type variable from the class header.  So in class C above, the first argument position of T is “shared”; and in class D, the second argument position of S is shared.</span><span style="font-size: 11pt; font-family: Calibri, sans-serif; "><o:p></o:p></span></p><p class="MsoListParagraph" style="margin-right: 0cm; margin-left: 36pt; font-size: 12pt; font-family: 'Times New Roman', serif; margin-bottom: 6pt; text-indent: -18pt; "><span style="font-family: Symbol; ">·</span><span style="font-size: 7pt; ">        <span class="apple-converted-space"> </span></span><span style="font-family: Calibri, sans-serif; ">A instance for an associated type (in a class instance declaration) cf 7.7.3.1 must have</span><span style="font-size: 11pt; font-family: Calibri, sans-serif; "><o:p></o:p></span></p><p class="MsoListParagraph" style="margin-right: 0cm; margin-left: 72pt; font-size: 12pt; font-family: 'Times New Roman', serif; margin-bottom: 6pt; text-indent: -18pt; "><span style="font-family: 'Courier New'; ">o</span><span style="font-size: 7pt; ">  <span class="apple-converted-space"> </span></span><span style="font-family: Calibri, sans-serif; ">type variables in the non-shared argument positions, and</span><span style="font-size: 11pt; font-family: Calibri, sans-serif; "><o:p></o:p></span></p><p class="MsoListParagraph" style="margin-right: 0cm; margin-left: 72pt; font-size: 12pt; font-family: 'Times New Roman', serif; margin-bottom: 6pt; text-indent: -18pt; "><span style="font-family: 'Courier New'; ">o</span><span style="font-size: 7pt; ">  <span class="apple-converted-space"> </span></span><span style="font-family: Calibri, sans-serif; ">an exact copy of the corresponding instance header type in the shared positions</span><span style="font-size: 11pt; font-family: Calibri, sans-serif; "><o:p></o:p></span></p><p class="MsoListParagraph" style="margin-right: 0cm; margin-left: 36pt; font-size: 12pt; font-family: 'Times New Roman', serif; margin-bottom: 6pt; text-indent: -18pt; "><span style="font-family: Symbol; ">·</span><span style="font-size: 7pt; ">        <span class="apple-converted-space"> </span></span><span style="font-family: Calibri, sans-serif; ">For each associated type you can have</span><span style="font-size: 11pt; font-family: Calibri, sans-serif; "><o:p></o:p></span></p><p class="MsoListParagraph" style="margin-right: 0cm; margin-left: 72pt; font-size: 12pt; font-family: 'Times New Roman', serif; margin-bottom: 6pt; text-indent: -18pt; "><span style="font-family: 'Courier New'; ">o</span><span style="font-size: 7pt; ">  <span class="apple-converted-space"> </span></span><span style="font-family: Calibri, sans-serif; ">at most one default declaration in the class declaration</span><span style="font-size: 11pt; font-family: Calibri, sans-serif; "><o:p></o:p></span></p><p class="MsoListParagraph" style="margin-right: 0cm; margin-left: 72pt; font-size: 12pt; font-family: 'Times New Roman', serif; margin-bottom: 6pt; text-indent: -18pt; "><span style="font-family: 'Courier New'; ">o</span><span style="font-size: 7pt; ">  <span class="apple-converted-space"> </span></span><span style="font-family: Calibri, sans-serif; ">at most one type instance declaration in the class instance declaration</span><span style="font-size: 11pt; font-family: Calibri, sans-serif; "><o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 6pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: Calibri, sans-serif; "> </span><span style="font-size: 11pt; font-family: Calibri, sans-serif; "><o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 6pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: Calibri, sans-serif; "> </span><span style="font-size: 11pt; font-family: Calibri, sans-serif; "><o:p></o:p></span></p><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-family: Helvetica, sans-serif; ">_______________________________________________<br>ghc-devs mailing list<br><a href="mailto:ghc-devs@haskell.org" style="color: purple; text-decoration: underline; "><span style="color: rgb(149, 79, 114); ">ghc-devs@haskell.org</span></a><br><a href="http://www.haskell.org/mailman/listinfo/ghc-devs" style="color: purple; text-decoration: underline; "><span style="color: rgb(149, 79, 114); ">http://www.haskell.org/mailman/listinfo/ghc-devs</span></a><o:p></o:p></span></div></blockquote></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><o:p> </o:p></div></div></div></div>_______________________________________________<br>Glasgow-haskell-users mailing list<br><a href="mailto:Glasgow-haskell-users@haskell.org" style="color: purple; text-decoration: underline; ">Glasgow-haskell-users@haskell.org</a><br><a href="http://www.haskell.org/mailman/listinfo/glasgow-haskell-users" style="color: purple; text-decoration: underline; ">http://www.haskell.org/mailman/listinfo/glasgow-haskell-users</a></div></blockquote></div><br></body></html>