<div dir="ltr"><div style class="markdown-here-wrapper" id="markdown-here-wrapper-125992"><p style="margin:1.2em 0px!important">+1 from me; I think this is why I have <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px 3px 3px 3px;display:inline">let s = id :: String -&gt; String</code> in my <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px 3px 3px 3px;display:inline">~/.ghci</code> and I agree the usefulness of being able to add other <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px 3px 3px 3px;display:inline">IsString [a]</code> instances is debatable and dubious, and the benefits from improved defaulting of far greater value here.</p>


</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Aug 24, 2013 at 7:52 PM, Edward Kmett <span dir="ltr">&lt;<a href="mailto:ekmett@gmail.com" target="_blank">ekmett@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>I&#39;ve been chewing on this one for a long time, and finally decided to post it after being bitten by it <i>again</i>.</div>

<div><br></div>Right now we have a very fragile instance in <font face="courier new, monospace">base</font> for<div>
<br></div><div><font face="courier new, monospace">instance IsString String where</font></div><div><font face="courier new, monospace">   fromString = id</font></div><div><br></div><div>This is fragile because once you turn on <font face="courier new, monospace">OverloadedStrings</font></div>


<div><br></div><div><font face="courier new, monospace">length &quot;hello&quot;</font></div><div><br></div><div>won&#39;t work any more, because all it knows is that it has a <font face="courier new, monospace">[a]</font> such that it needs an <font face="courier new, monospace">IsString [a]</font> instance, but it can&#39;t use defaulting to select the <font face="courier new, monospace">[Char]</font> instance we&#39;ve defined, and so you have to burden it with a type annotation.</div>


<div><br></div><div><div><font face="courier new, monospace">&gt;&gt;&gt; :set -XOverloadedStrings</font></div><div><font face="courier new, monospace">&gt;&gt;&gt; length &quot;hello&quot;</font></div><div><font face="courier new, monospace"><br>


</font></div><div><font face="courier new, monospace">&lt;interactive&gt;:3:8:</font></div><div><font face="courier new, monospace">    No instance for (Data.String.IsString [a0])</font></div><div><font face="courier new, monospace">      arising from the literal `&quot;hello&quot;&#39;</font></div>


<div><font face="courier new, monospace">    The type variable `a0&#39; is ambiguous</font></div><div><font face="courier new, monospace">    Possible fix: add a type signature that fixes these type variable(s)</font></div>


<div><font face="courier new, monospace">    Note: there is a potential instance available:</font></div><div><font face="courier new, monospace">      instance Data.String.IsString [Char] -- Defined in `Data.String&#39;</font></div>


<div><font face="courier new, monospace">    Possible fix:</font></div><div><font face="courier new, monospace">      add an instance declaration for (Data.String.IsString [a0])</font></div><div><font face="courier new, monospace">    In the first argument of `length&#39;, namely `&quot;hello&quot;&#39;</font></div>


<div><font face="courier new, monospace">    In the expression: length &quot;hello&quot;</font></div><div><font face="courier new, monospace">    In an equation for `it&#39;: it = length &quot;hello&quot;</font></div></div>


<div><br></div><div>I would like to replace this instance with</div><div><br></div><div><font face="courier new, monospace">instance a ~ Char =&gt; IsString [a] where</font></div><div><font face="courier new, monospace">  fromString = id</font></div>


<div><br></div><div>This will make <font face="courier new, monospace">OverloadedStrings</font> work much better with the list-specific combinators, reducing the number of type annotations required by users who hack on, say, web-apps in Haskell where both <font face="courier new, monospace">OverloadedStrings</font> is a common extension and, frankly, the users are often the least equipped to deal with and understand the issue. </div>


<div><br></div><div>The cost of this instance is that someone else can&#39;t come along and make an instance of IsString for another &#39;character-like&#39; type and get the <font face="courier new, monospace">String</font>-like behavior with magic list interoperability without some kind of wrapper.</div>


<div><br></div><div>However, I&#39;ve yet to see any such instances, and I&#39;d likely look down my nose at such an instance in the first place. ;) The current pain is real and the space of instances affected seems both largely theoretical and a bad idea to begin with. </div>


<div><br></div><div>The instance is already guarded from use by NHC by an <font face="courier new, monospace">#ifdef</font>, which limits objections on portability grounds.</div><div><br></div><div>Discussion Period: 2 Weeks</div>


</div>
<br>_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/libraries" target="_blank">http://www.haskell.org/mailman/listinfo/libraries</a><br>
<br></blockquote></div><br></div>