<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>If we can't find any major problems with the dictionary casting once it is implemented, I'm fully on board. </div><div><br></div><div>This does seem to me to have the ugly consequence of splitting the long term solutions for Coercible and GND, but I can fully understand the appeal of finally plugging the GND issue!<br><br>-Edward</div><div><br>On Oct 16, 2013, at 9:36 AM, Simon Peyton-Jones <<a href="mailto:simonpj@microsoft.com">simonpj@microsoft.com</a>> wrote:<br><br></div><blockquote type="cite"><div>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Verdana;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:36.0pt;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
.MsoPapDefault
        {mso-style-type:export-only;
        margin-top:6.0pt;
        margin-right:0cm;
        margin-bottom:6.0pt;
        margin-left:0cm;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:1735545792;
        mso-list-type:hybrid;
        mso-list-template-ids:1424784506 134807553 134807555 134807557 134807553 134807555 134807557 134807553 134807555 134807557;}
@list l0:level1
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Symbol;}
@list l0:level2
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:"Courier New";}
@list l0:level3
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Wingdings;}
@list l0:level4
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Symbol;}
@list l0:level5
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:"Courier New";}
@list l0:level6
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Wingdings;}
@list l0:level7
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Symbol;}
@list l0:level8
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:"Courier New";}
@list l0:level9
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Wingdings;}
ol
        {margin-bottom:0cm;}
ul
        {margin-bottom:0cm;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->


<div class="WordSection1">
<p class="MsoNormal" style="margin-left:36.0pt">As it stands, all roles do for me now is break code that previously worked, and infer constraints that are too tight to let Coercible be useful for anything but trivial examples. Both of these issues seem addressable,
 but if we lock in the current solution I fear we'll get stuck in a local optimum, with a much better solution just over the hill.<o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-18.0pt;mso-list:l0 level1 lfo1"><!--[if !supportLists]--><span style="font-size:11.0pt;font-family:Symbol;color:#1F497D;mso-fareast-language:EN-US"><span style="mso-list:Ignore">·<span style="font:7.0pt "Times New Roman"">        
</span></span></span><!--[endif]--><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;mso-fareast-language:EN-US">Coercible: I have no problem with it being not useful for “anything but trivial examples”.  I don’t really agree with this
 assessment, but even if it were true it would not matter.  It’s an experimental feature; we can change it; getting feedback would be good; we are absolutely not locking in
<i>anything</i>.<br>
<br>
<o:p></o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-18.0pt;mso-list:l0 level1 lfo1"><!--[if !supportLists]--><span style="font-size:11.0pt;font-family:Symbol;color:#1F497D;mso-fareast-language:EN-US"><span style="mso-list:Ignore">·<span style="font:7.0pt "Times New Roman"">        
</span></span></span><!--[endif]--><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;mso-fareast-language:EN-US">GND.  Let’s be clear that while roles may break code that previously work, they
<b>also</b> prevent seg faults that previously happened.  There are many programs that would work, but are rejected by the type checker.  (eg ord (if True then ‘c’ else Just ‘x’)).  You’ve just grown used to having these dangerous programs accepted! 
<o:p></o:p></span></p>
<p class="MsoListParagraph"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoListParagraph"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;mso-fareast-language:EN-US">Usually we take soundness pretty seriously, and that’s what roles restore.<o:p></o:p></span></p>
<p class="MsoListParagraph"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoListParagraph"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;mso-fareast-language:EN-US">In any case, as in my last email, I think we know how to fix the issues that are paining you.  I agree that it is worth doing
 this before the release.<o:p></o:p></span></p>
<p class="MsoListParagraph"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoListParagraph" style="margin-left:0cm"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;mso-fareast-language:EN-US">Does that sound ok?<o:p></o:p></span></p>
<p class="MsoListParagraph"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoListParagraph" style="margin-left:0cm"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;mso-fareast-language:EN-US">Simon<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif""> Edward Kmett [<a href="mailto:ekmett@gmail.com">mailto:ekmett@gmail.com</a>]
<br>
<b>Sent:</b> 12 October 2013 18:25<br>
<b>To:</b> Simon Peyton-Jones<br>
<b>Cc:</b> Richard Eisenberg; Stephanie Weirich; Joachim Breitner; <a href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a> Devs<br>
<b>Subject:</b> Re: small improvement to roles mechanism<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
On Sat, Oct 12, 2013 at 8:00 AM, Simon Peyton-Jones <<a href="mailto:simonpj@microsoft.com" target="_blank">simonpj@microsoft.com</a>> wrote:<o:p></o:p></p>
<div>
<div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p style="mso-margin-top-alt:5.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:35.7pt">
<span style="font-size:11.0pt;font-family:Symbol;color:#1F497D"><br>
·</span><span style="font-size:7.0pt;color:#1F497D">         </span><span style="font-size:11.0pt;font-family:"Verdana","sans-serif";color:#1F497D">The current proposal, which I am happy with, is to
<i>express the answer to this question in T’s role annotation</i>.  There is design wiggle-room here:</span><o:p></o:p></p>
<p style="mso-margin-top-alt:5.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:72.0pt">
<span style="font-size:11.0pt;font-family:"Courier New";color:#1F497D">o</span><span style="font-size:7.0pt;color:#1F497D">  
</span><span style="font-size:11.0pt;font-family:"Verdana","sans-serif";color:#1F497D">If there is no user-supplied annotation, what should the default be?  The inferred (lease-restrictive) role, or the Nominal (most restrictive) role?
</span><o:p></o:p></p>
<p style="mso-margin-top-alt:5.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:72.0pt">
<span style="font-size:11.0pt;font-family:"Courier New";color:#1F497D">o</span><span style="font-size:7.0pt;color:#1F497D">  
</span><span style="font-size:11.0pt;font-family:"Verdana","sans-serif";color:#1F497D">How expressive is the role annotation language, especially where type constructors are concerned?</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt;margin-left:36.0pt">
<span style="font-size:11.0pt;font-family:"Verdana","sans-serif";color:#1F497D">So the design is not fully stable here, but I think the principle, that T’s role ascription answers the question, is sound.</span><o:p></o:p></p>
<p style="mso-margin-top-alt:5.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:36.0pt">
<span style="font-size:11.0pt;font-family:Symbol;color:#1F497D">·</span><span style="font-size:7.0pt;color:#1F497D">        
</span><span style="font-size:11.0pt;font-family:"Verdana","sans-serif";color:#1F497D">The current, fairly inexpressive role annotation language makes three Hackage packages (a tiny number) fail to compile because their use of GND is rejected.  They have fairly
 few dependencies, so in all 18 packages break.  Each of the three can be fixed with very modest changes. This does not sound like a lot of pain to me.</span><o:p></o:p></p>
</div>
</div>
</blockquote>
<div>
<div>
<p class="MsoNormal">It also currently means that any sort of transformer or composition infers as having a nominal role for its arguments. This rather greatly reduces the applicability of Coercible. The suggestion Richard made at the start of this thread starts
 to hint at how we might get something that lacks these limitations. It might be good to have some time to explore this corner of the design space without the looming thread of imminent release.<o:p></o:p></p>
</div>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p style="mso-margin-top-alt:5.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:36.0pt">
<span style="font-size:11.0pt;font-family:"Verdana","sans-serif";color:#1F497D">That said, if you think it best, I’d be perfectly happy to make GND failure into a warning for one release cycle.  (I wouldn’t do that myself, but I’m quite willing to be guided
 on this one.)</span><o:p></o:p></p>
</div>
</div>
</blockquote>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p style="margin-bottom:6.0pt"><span style="font-size:11.0pt;font-family:"Verdana","sans-serif";color:#1F497D">In short:</span><o:p></o:p></p>
<p style="mso-margin-top-alt:5.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:36.0pt">
<span style="font-size:11.0pt;font-family:Symbol;color:#1F497D">·</span><span style="font-size:7.0pt;color:#1F497D">        
</span><span style="font-size:11.0pt;font-family:"Verdana","sans-serif";color:#1F497D">Coercible is opt-in anyway</span><o:p></o:p></p>
<p style="mso-margin-top-alt:5.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:36.0pt">
<span style="font-size:11.0pt;font-family:Symbol;color:#1F497D">·</span><span style="font-size:7.0pt;color:#1F497D">        
</span><span style="font-size:11.0pt;font-family:"Verdana","sans-serif";color:#1F497D">If you prefer, GND failure can be a warning</span><o:p></o:p></p>
</div>
</div>
</blockquote>
<p class="MsoNormal">I am perhaps a bit over-cautious, but I'd feel much more comfortable with the GND failure as a warning for a release cycle. That gives end users a year to get their code in order. GND is the kind of thing used more by folks writing applications
 than in library code, so I am somewhat concerned that the Hackage summary may be optimistic, so I'm inclined to tread cautiously here.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">From a release management standpoint folks with a short maintenance window would then be able to write code with role annotations by 7.10 so that their code would work with 7.8 and 7.10, and users with longer maintenance windows could put
 in the CPP pragmas necessitated by this change, and it buys us breathing room to see if Richard's suggestion can be adapted to get something that gives us more of the power of full on role parametricity without having to change the typechecker.<o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Verdana","sans-serif";color:#1F497D">What’s not to like?  Am I missing anything?</span><o:p></o:p></p>
</div>
</div>
</blockquote>
<div>
<div>
<p class="MsoNormal">As it stands, all roles do for me now is break code that previously worked, and infer constraints that are too tight to let Coercible be useful for anything but trivial examples. Both of these issues seem addressable, but if we lock in
 the current solution I fear we'll get stuck in a local optimum, with a much better solution just over the hill.<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">-Edward<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif"">
 ghc-devs [mailto:<a href="mailto:ghc-devs-bounces@haskell.org" target="_blank">ghc-devs-bounces@haskell.org</a>]
<b>On Behalf Of </b>Richard Eisenberg<br>
<b>Sent:</b> 12 October 2013 03:20<br>
<b>To:</b> Edward Kmett<br>
<b>Cc:</b> Stephanie Weirich; Joachim Breitner; <a href="mailto:ghc-devs@haskell.org" target="_blank">
ghc-devs@haskell.org</a> Devs</span><o:p></o:p></p>
<div>
<p class="MsoNormal"><br>
<b>Subject:</b> Re: small improvement to roles mechanism<o:p></o:p></p>
</div>
</div>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">I tend to agree with the above remarks and have been silencing the little voice in the back of my head that has suggested we pull roles out of 7.8. Ever since the debate about default
 roles vis-a-vis abstract datatypes started, I've been wondering if we're being a little hasty here.<o:p></o:p></p>
</div>
<div>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">As we think about how to proceed, I think it's worth teasing apart the two different strains in all of this: enforcing type safety and enforcing abstraction.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Roles, as they are, do a quite good job of enforcing type safety. When compiling all of Hackage, the majority of the breakage from roles was due to real type goofs in programs.
 A total of 18 packages (out of the 3,234 that compile with 7.6.3) fail to compile because of deficiencies in the role system, including transitive breakage (i.e., packages that depend on broken packages). A small change in the GND check discussed in this forum
 would fix 11 of these, leaving only 7. Given that type systems are necessarily conservative, I'm not too displeased with this result -- the 3 packages that would need to be changed would require only a few lines of code. Given this result, I disagree with
 Edward's claim that roles will provide the biggest pain in upgrading from 7.6 to 7.8.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">That said, I of course would like to do better and would prefer to 0 broken packages due to deficiencies in the role system.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">On the other hand, roles as they are do a poor job of enforcing abstraction. But, before roles came along, there wasn't anything resembling a way of enforcing abstraction in the
 context of GND. So, this isn't exactly a new problem. The only thing (I think) exacerbating the problem is that Coercible now makes it easier than ever to break abstraction.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">That said, I of course would like to fix this problem, too.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">So, how to proceed? There are a few options:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">1. I'll change the GND check to be a little more liberal, and we release roles in 7.8. I could notify the authors of the three packages that need to be updated because of the lack
 of role abstraction.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">2. Like #1, but disallow Coercible. This way, the abstraction problem is no worse than it was before. (Apologies to Joachim if he minds this suggestion.)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">3. Pull roles out of 7.8, giving us a little more time to Get It Right.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">It's a little hard for me to choose between these options, but I think it's good to be conservative in language design of a language in real use, so I lean slightly toward option
 #3. Doing this is very feasible from a technical standpoint -- it's easy to turn off the checks.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">If we go with #3, given the flux in the design, I'm even uncertain about the idea of warnings in 7.8. It would all feel a little silly if we issue these warnings and then change
 the design between 7.8 and 7.10 just enough to make the warnings wrong. I think warnings in 7.8.2 is a better idea.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">As for Johan's remark that the feature should have been vetted more thoroughly -- I completely agree, and I'll take responsibility for that decision. I did do some ad-hoc testing
 against packages on Hackage known to use GND, but the testing was not as thorough as it could have been. That said, I'm not sure anything would have played out too differently had I done more extensive testing; the results were about as I expected.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">I do greatly appreciate everyone's feedback and interest in this!<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Richard<o:p></o:p></p>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">On Oct 11, 2013, at 7:55 PM, Edward Kmett wrote:<o:p></o:p></p>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:12.0pt"><o:p> </o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">I have to agree that I'm somewhat disturbed by the fact that we're pushing this out and we're still finding issues with it this close to release. =(<o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">It strikes me that the role machinery is going to be the cause of the majority of the pain users have upgrading to 7.8, and if I try to pretend to be Mark Lentczner for a bit, it
 makes it seem highly likely that it'd be the kind of thing that keeps 7.8 from going into a Haskell Platform, causing the groundhog to see his shadow, leaving us with another year of 7.4 or 7.6.x.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">I know we're at the 5 yard line, but to metaphorically throw a bunch of metaphors in a blender, if we had to make the uncomfortable decision to perform triage and ask if it should
 be put off (at least enforcing) the roles machinery to 7.10, so we can know we have it right, how much fallout would there be? Off the top of my head, of course Joachim's work on Coercible would be affected. What else?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">One option might be to pull the teeth of role inference for 7.8 with regards to GND, and turn bad roles use into a warning for a release cycle. That would give the community a year
 to get role annotations in place before generalized newtype deriving for their code just stopped working.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">If we ship with this the way it stands, I don't foresee the community reaction being good.<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">With its teeth pulled, then GND could proceed as before, but with the added detailed warnings from the dictionary coercions helping to guide folks to make the change. By the time
 we'd be enforcing correct role annotations most folks would have them in place to silence the warnings.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">-Edward<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:12.0pt"> <o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">On Fri, Oct 11, 2013 at 7:15 PM, Johan Tibell <<a href="mailto:johan.tibell@gmail.com" target="_blank">johan.tibell@gmail.com</a>> wrote:<o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt">
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Oh and let me add: it would have been nice to have the people actually making these change to have done an impact analysis on Hackage, instead of discovering potential issues a
 week or two before the release. Lets try to do that next time.<o:p></o:p></p>
</div>
<div>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:12.0pt"> <o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">On Fri, Oct 11, 2013 at 4:14 PM, Johan Tibell <<a href="mailto:johan.tibell@gmail.com" target="_blank">johan.tibell@gmail.com</a>> wrote:<o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt">
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Let me start by saying that I'm happy we're trying to fix the GND problem. Thanks for working on that.<o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">That being said: is this ready for mainstream consumption? We're forcing this on everyone without any language pragma or flags to opt-in/out. That is bad if we're not sure we're
 doing the right thing in some cases or if we're causing spurious failures. At ICFP I got the impression that very few people will be affected, but Bryan's result suggests there are more people than I thought.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
</div>
<div>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:12.0pt"> <o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">On Thu, Oct 10, 2013 at 8:26 PM, Richard Eisenberg <<a href="mailto:eir@cis.upenn.edu" target="_blank">eir@cis.upenn.edu</a>> wrote:<o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt">
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">In Bryan's recent test of GHC 7.8 against all of Hackage, there were three spurious errors caused by lack of role abstraction. Here are the class definitions where a nominal parameter
 is inferred, probably against the wishes of the author:<br>
<br>
from logict-0.2.3/Control.Monad.Logic.Class:<br>
> class (MonadPlus m) => MonadLogic m where<br>
>     msplit     :: m a -> m (Maybe (a, m a))<br>
<br>
from monadLib-3.5.2/MonadLib:<br>
> class (Monad m) => ReaderM m i | m -> i where<br>
>   ask :: m i<br>
<br>
from base/Control.Arrow:<br>
> class Arrow a => ArrowApply a where<br>
>     app :: a (a b c, b) c<br>
<br>
In each of these, the last parameter of the class is given a nominal role because it appears as the parameter of a type variable. However, in each case, it appears as the parameter of a *class* type variable. This means that, if we somehow knew that the class
 author wanted the class to be usable with GND, we could simply check every instance declaration for that class to make sure that the relevant concrete instantiation has the right role. For example, when the user writes, for example<br>
<br>
> instance ArrowApply Foo where …<br>
<br>
we check that Foo's first parameter has a representational role. If it doesn't, then the instance is rejected.<br>
<br>
An alternative, somewhat heavier idea would be to represent roles as class constraints. We could have<br>
<br>
> class NextParamNominal (c :: k)<br>
> class NextParamRepresentational (c :: k)<br>
<br>
GHC could "generate" instances for every datatype definition. For example:<br>
<br>
> type role Map nominal representational<br>
> data Map k v = …<br>
<br>
would induce<br>
<br>
> instance NextParamNominal Map<br>
> instance NextParamRepresentational (Map k)<br>
<br>
Users would not be able to write these instances -- they would have to be generated by GHC. (Alternatively, there could be no instances, just a little magic in the constraint solver. Somewhat like Coercible.)<br>
<br>
Then, the classes above would just have to add a superclass, like this:<br>
<br>
> class (Arrow a, NextParamRepresentational a) => ArrowApply a where<br>
>   app :: a (a b c, b) c<br>
<br>
The role inference mechanism would be made aware of role constraints and use this one to derive that ArrowApply is OK for GND.<br>
<br>
This "heavier" approach has a similar upshot to the first idea of just checking at instance declarations, but it is more customizable and transparent to users (I think).<br>
<br>
<br>
I'm not sure I'm advocating for this change (or volunteering to implement before the release candidate), but I wanted to document the idea and get any feedback that is out there. This would fix the breakage we've seen without totally changing the kind system.<br>
<br>
Thanks,<br>
Richard<br>
<br>
PS: Due credit is to migmit for suggesting the type-class idea on glasgow-haskell-users.<br>
_______________________________________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org" target="_blank">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><o:p></o:p></p>
</blockquote>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
</div>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:12.0pt"><br>
_______________________________________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org" target="_blank">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><o:p></o:p></p>
</blockquote>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
</blockquote>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
</div>


</div></blockquote></body></html>