<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=utf-8"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        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.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.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Arial","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
@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:825362904;
        mso-list-type:hybrid;
        mso-list-template-ids:-2007331116 -51847724 134807577 134807579 134807567 134807577 134807579 134807567 134807577 134807579;}
@list l0:level1
        {mso-level-number-format:alpha-lower;
        mso-level-text:"\(%1\)";
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level2
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level3
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l0:level4
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level5
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level6
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l0:level7
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level8
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level9
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
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=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'>Doug suggested this below:<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal>“Capture can be prevented by declaring type signatures for local<br>variables. &nbsp;The compiler might warn when such defensive<br>declarations are lacking.”<o:p></o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'>I think what Doug is proposing is that it be a warning *<b>not</b>* to include a type signature for any local declaration in an instance, and continue to be an error to provide a type signature for any class member implementation. That would mean that if you started warnings-free, a change in the type class that captured a local would always result in an error.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'>The downsides I see are that<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:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'><span style='mso-list:Ignore'>(a)<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp; </span></span></span><![endif]><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'>it doesn’t seem very intuitive for the presence or absence of type signatures to signify whether something is local or not<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:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'><span style='mso-list:Ignore'>(b)<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp; </span></span></span><![endif]><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'>GHC has a recent extension “InstanceSigs” that allows signatures to be given on class members<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'>Overall I like the idea of regularizing the language and have wanted something like this myself in the past, but Edward’s objection feels significant to me.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> haskell-prime-bounces@haskell.org [mailto:haskell-prime-bounces@haskell.org] <b>On Behalf Of </b>Edward Kmett<br><b>Sent:</b> 01 May 2013 02:46<br><b>To:</b> Doug McIlroy<br><b>Cc:</b> haskell-prime@haskell.org Prime<br><b>Subject:</b> Re: relaxing instance declarations<o:p></o:p></span></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><div><p class=MsoNormal>The problem I see with this is it becomes very brittle to just silently accept bad class member names.<o:p></o:p></p><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>Before, if I had a method<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>class Foo a where<o:p></o:p></p></div><div><p class=MsoNormal>&nbsp; bar :: a -&gt; Int<o:p></o:p></p></div><div><p class=MsoNormal>&nbsp; bar _ = 0<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>and I went to implement something with a typo<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>instance Foo Int where<o:p></o:p></p></div><div><p class=MsoNormal>&nbsp; baz = id<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>then I'd get an error, but your proposal it'd just silently be accepted, and lead to to long nights searching for why my instance wasn't doing what I expected long after I'd shipped my product.<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>This kind of class isn't an academic concern, many real world classes are defined with 2-3 members circularly. Consider Foldable or Traversable.<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>newtype Baz = Baz a<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>instance Foldable Baz where<o:p></o:p></p></div><div><p class=MsoNormal>&nbsp; foldmap f (Baz a) = f a<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>is an innocent typo that would then just mean that foldMap when applied to Baz will silently loop forever with no warning to the programmer. Traversable Baz behaves similarly with the cyclic between sequenceA+fmap and traverse.<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>I'd argue that I've made typos on member names <b>far</b> more often than I've wanted this feature.<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>In fact, I've actually tried to live with a very similar lexical scoping design in a toy language of mine I called Kata. In Kata, you could just introduce new members by writing them in a 'public' block, and constrain subclasses by putting in members without definitions, but it was sufficiently brittle that I wound up adding another syntactic construct which could only be used to instantiate definitions not make new names. That resolve the issue and made the language much nicer to play around in.<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>I'd really rather not switch from a design that is robust and usually does the right thing to one that is more brittle and prone to introducing hard to find bugs. =(<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>-Edward<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div></div><div><p class=MsoNormal style='margin-bottom:12.0pt'><o:p>&nbsp;</o:p></p><div><p class=MsoNormal>On Tue, Apr 30, 2013 at 7:05 PM, Doug McIlroy &lt;<a href="mailto:doug@cs.dartmouth.edu" target="_blank">doug@cs.dartmouth.edu</a>&gt; wrote:<o:p></o:p></p><p class=MsoNormal>Max's idea (see below) of a second where clause is cute, but<br>not sanctioned by Haskell syntax.<br><br>Iavor wrote, &quot;It would be quite arbitrary to restrict this only<br>to instances.&quot;<br><br>Actually what I have in mind is to make the language MORE<br>consistent, by eliminating distinctions between instance-wheres<br>and ordinary declaration-wheres. &nbsp;Currently instance-wheres may<br>only declare class methods, while declaration-wheres may declare<br>variables at will. &nbsp;Also instance-wheres may not declare type<br>signatures, while declaration-wheres may. &nbsp;I propose dropping<br>these restrictions on instance-wheres.<br><br>Hazard: Adding a method to an existing class could accidentally<br>capture a name that was previously local to an instance-where.<br>Capture can be prevented by declaring type signatures for local<br>variables. &nbsp;The compiler might warn when such defensive<br>declarations are lacking.<br><br>Doug<br><br>On Mon, 29 Apr 2013 15:56 Iavor Diatchki &lt;<a href="mailto:iavor.diatchki@gmail.com">iavor.diatchki@gmail.com</a>&gt; wrote<o:p></o:p></p><div><div><p class=MsoNormal style='margin-bottom:12.0pt'><br>Hello,<br><br>I think that if we want something along those lines, we should consider a<br>more general construct that allows declarations to scope over other<br>declarations (like SML's `local` construct). &nbsp;It would be quite arbitrary<br>to restrict this only to instances.<br><br>-Iavor<br><br><br><br>On Mon, Apr 29, 2013 at 2:41 PM, Max Bolingbroke &lt;<a href="mailto:batterseapower@hotmail.com">batterseapower@hotmail.com</a><br>&gt; wrote:<br><br>&gt; You could probably get away with just using two &quot;where&quot; clauses:<br>&gt;<br>&gt; instance Foo a where<br>&gt; &nbsp; &nbsp; bar = ...<br>&gt; &nbsp; where<br>&gt; &nbsp; &nbsp; auxilliary = ...<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt; On 28 April 2013 18:42, Edward Kmett &lt;<a href="mailto:ekmett@gmail.com">ekmett@gmail.com</a>&gt; wrote:<br>&gt;<br>&gt;&gt; Makes sense. I'm not sure what a good syntactic story would be for that<br>&gt;&gt; feature though. Just writing down member names that aren't in the class<br>&gt;&gt; seems to be too brittle and error prone, and new keywords seems uglier than<br>&gt;&gt; the current situation.<br>&gt;&gt;<br>&gt;&gt; Sent from my iPad<br>&gt;&gt;<br>&gt;&gt; On Apr 28, 2013, at 1:24 PM, Doug McIlroy &lt;<a href="mailto:doug@cs.dartmouth.edu">doug@cs.dartmouth.edu</a>&gt; wrote:<br>&gt;&gt;<br>&gt;&gt; &gt; Not always. For example, you can't mess with the declaration<br>&gt;&gt; &gt; of a standard class, such as Num.<br>&gt;&gt; &gt;<br>&gt;&gt; &gt; On Sun, Apr 28, 2013 at 12:06 PM, Edward Kmett &lt;<a href="mailto:ekmett@gmail.com">ekmett@gmail.com</a>&gt;<br>&gt;&gt; wrote:<br>&gt;&gt; &gt;<br>&gt;&gt; &gt;&gt; You can always put those helper functions in the class and then just<br>&gt;&gt; not<br>&gt;&gt; &gt;&gt; export them from the module.<br>&gt;&gt; &gt;<br>&gt;&gt; &gt; On Sun, Apr 28, 2013 at 10:49 AM, Doug McIlroy &lt;<a href="mailto:doug@cs.dartmouth.edu">doug@cs.dartmouth.edu</a><br>&gt;&gt; &gt;wrote:<br>&gt;&gt; &gt;<br>&gt;&gt; &gt;&gt; Is there any strong reason why the where clause in an instance<br>&gt;&gt; &gt;&gt; declaration cannot declare anything other than class<br>&gt;&gt; &gt;&gt; operators? If not, I suggest relaxing the restriction.<br>&gt;&gt; &gt;&gt;<br>&gt;&gt; &gt;&gt; It is not unusual for declarations of class operators to<br>&gt;&gt; &gt;&gt; refer to special auxiliary functions. Under current rules<br>&gt;&gt; &gt;&gt; such functions have to be declared outside the scope in<br>&gt;&gt; &gt;&gt; which they are used.<br>&gt;&gt; &gt;&gt;<br>&gt;&gt; &gt;&gt; Doug McIlroy<br>&gt;&gt;<br>&gt;&gt; _______________________________________________<br>&gt;&gt; Haskell-prime mailing list<br>&gt;&gt; <a href="mailto:Haskell-prime@haskell.org">Haskell-prime@haskell.org</a><br>&gt;&gt; <a href="http://www.haskell.org/mailman/listinfo/haskell-prime" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-prime</a><br>&gt;&gt;<br>&gt;&gt;<br>&gt;<br>&gt; _______________________________________________<br>&gt; Haskell-prime mailing list<br>&gt; <a href="mailto:Haskell-prime@haskell.org">Haskell-prime@haskell.org</a><br>&gt; <a href="http://www.haskell.org/mailman/listinfo/haskell-prime" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-prime</a><br>&gt;<br>&gt;<o:p></o:p></p></div></div><p class=MsoNormal>Content-Type: text/html; charset=UTF-8<o:p></o:p></p></div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div></div> <br>
 <BR/><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><p class=MsoNormal><span lang=EN-US style='font-size:8.0pt;font-family:Courier'>===============================================================================<br>This material has been prepared by individual sales and/or trading personnel and does not<br>constitute investment research.  Please follow the attached hyperlink to an important disclaimer:<br><a href="http://www.credit-suisse.com/americas/legal/salestrading">http://www.credit-suisse.com/americas/legal/salestrading</a><br>===============================================================================<o:p></o:p></span></p></html> <BR/><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><p class=MsoNormal><span lang=EN-US style='font-size:8.0pt;font-family:Courier'>==============================================================================<br>Please access the attached hyperlink for an important electronic communications disclaimer:<br><a href="http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html">http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html</a><br>==============================================================================<o:p></o:p></span></p></html> <br>
</body></html>