<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<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;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin-top:6.0pt;
        margin-right:0cm;
        margin-bottom:6.0pt;
        margin-left:0cm;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:6.0pt;
        margin-right:0cm;
        margin-bottom:6.0pt;
        margin-left:36.0pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
p.Code, li.Code, div.Code
        {mso-style-name:Code;
        margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:36.0pt;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Courier New";
        mso-fareast-language:EN-US;}
span.EmailStyle18
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@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:1186208949;
        mso-list-type:hybrid;
        mso-list-template-ids:54284238 134807553 134807555 134807557 134807553 134807555 134807557 134807553 134807555 134807557;}
@list l0:level1
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        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:\F0A7;
        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:\F0B7;
        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:\F0A7;
        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:\F0B7;
        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:\F0A7;
        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]-->
</head>
<body lang="EN-GB" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:12.0pt;color:#1F497D">Friends, in sending my message below, I should also have sent a link to<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;color:#1F497D">            <a href="https://ghc.haskell.org/trac/ghc/ticket/9242#comment:25">
https://ghc.haskell.org/trac/ghc/ticket/9242#comment:25</a><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;color:#1F497D">Comment 25 describes the semantics of OVERLAPPING/OVERLAPPABLE etc, which I signally failed to do in my message below, leading to confusion in the follow up messages.  My apologies for that.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;color:#1F497D">Some key points:<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:12.0pt;font-family:Symbol;color:#1F497D"><span style="mso-list:Ignore">·<span style="font:7.0pt "Times New Roman"">        
</span></span></span><![endif]><span style="font-size:12.0pt;color:#1F497D">There is a useful distinction between
<i>overlapping</i> and <i>overlappable</i>, but if you don’t want to be bothered with it you can just say OVERLAPS (which means both).<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:12.0pt;font-family:Symbol;color:#1F497D"><span style="mso-list:Ignore">·<span style="font:7.0pt "Times New Roman"">        
</span></span></span><![endif]><span style="font-size:12.0pt;color:#1F497D">Overlap between two candidate instances is allowed if
<i>either</i> has the relevant property.  This is a bit sloppy, but reduces the annotation burden.  Actually, with this per-instance stuff I think it’d be perfectly defensible to require both to be annotated, but that’s a different discussion.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;color:#1F497D">I hope that helps clarify.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;color:#1F497D">I’m really pretty certain that the basic proposal here is good: it implements the current semantics in a more fine-grained manner.  My main motivation was to signal the proposed deprecation of
 the global per-module flag –XoverlappingInstances.  Happily people generally seem fine with this.   It is, after all, precisely what deprecations are for (“the old thing still works for now, but it won’t do so for ever, and you should change as soon as is
 convenient”).<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;color:#1F497D">Thanks<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;color:#1F497D">Simon<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;color:#1F497D">                                                                                                                           
<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" style="margin:0cm;margin-bottom:.0001pt"><b><span lang="EN-US" style="mso-fareast-language:EN-GB">From:</span></b><span lang="EN-US" style="mso-fareast-language:EN-GB"> Libraries [mailto:libraries-bounces@haskell.org]
<b>On Behalf Of </b>Simon Peyton Jones<br>
<b>Sent:</b> 29 July 2014 10:11<br>
<b>To:</b> ghc-devs; GHC users; Haskell Libraries (libraries@haskell.org)<br>
<b>Subject:</b> Overlapping and incoherent instances<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-size:12.0pt">Friends<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt">One of GHC’s more widely-used features is overlapping (and sometimes incoherent) instances.  The user-manual documentation is
<a href="http://www.haskell.org/ghc/docs/latest/html/users_guide/type-class-extensions.html#instance-overlap">
here</a>.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt">The use of overlapping/incoherent instances is controlled by LANGUAGE pragmas: OverlappingInstances and IncoherentInstances respectively.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt">However the overlap/incoherent-ness is a property of the *<b>instance declaration</b>* itself, and has been for a long time.  Using LANGUAGE OverlappingInstances simply sets the “I am an overlapping instance”
 flag for every instance declaration in that module.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt">This is a Big Hammer.  It give no clue about *<b>which</b>* particular instances the programmer is expecting to be overlapped, nor which are doing the overlapping.    It brutally applies to every instance
 in the module.  Moreover, when looking at an instance declaration, there is no nearby clue that it might be overlapped.  The clue might be in the command line that compiles that module!<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt">Iavor has recently implemented per-instance-declaration pragmas, so you can say<o:p></o:p></span></p>
<p class="Code">instance {-# OVERLAPPABLE #-} Show a => Show [a] where …<o:p></o:p></p>
<p class="Code">instance {-# OVERLAPPING #-} Show [Char] where …<o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:12.0pt">This is much more precise (it affects only those specific instances) and it is much clearer (you see it when you see the instance declaration).<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt">This new feature will be in GHC 7.10 and I’m sure you will be happy about that. 
<b>But I propose also to deprecate the LANGUAGE pragmas OverlappingInstances and IncoherentInstances</b>, as way to encourage everyone to use the new feature instead of the old big hammer.  The old LANGUAGE pragmas will continue to work, of course, for at least
 another complete release cycle.  We could make that two cycles if it was helpful.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt">However, if you want deprecation-free libraries, it will entail a wave of library updates.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt">This email is just to warn you, and to let you yell if you think this is a bad idea.   It would actually not be difficult to retain the old LANGUAGE pragmas indefinitely – it just seems wrong not to actively
 push authors in the right direction.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt">These deprecations of course popped up in the test suite, so I’ve been replacing them with per-instance pragmas there too.  Interestingly in some cases, when looking for which instances needed the pragmas,
 I found…none. So OverlappingInstances was entirely unnecessary.  Maybe library authors will find that too!<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt">Simon<o:p></o:p></span></p>
</div>
</div>
</body>
</html>