<div dir="ltr">That seems worth pursuing. <div><br></div><div>If that works, it&#39;d turn the defaulting rules fix from a fishing expedition to simply adding a couple of extra classes to the list of approved basic defaultings.<div>
<br></div><div>-Edward</div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Aug 26, 2013 at 4:54 PM, Ganesh Sittampalam <span dir="ltr">&lt;<a href="mailto:ganesh@earth.li" target="_blank">ganesh@earth.li</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Couldn&#39;t it work (with suitable extensions to the list of blessed<br>
classes) with Henning&#39;s IsCharList suggestion? The unresolved constraint<br>
would be IsCharList a.<br>
<div class="im"><br>
On 26/08/2013 21:47, Edward Kmett wrote:<br>
&gt; The problem is ExtendedDefaultRules only works when the whole type is<br>
&gt; unknown. If we know part of the type e.g. that it is [a] for some a as<br>
&gt; we figure out from length, or that it is (f a), then it doesn&#39;t kick in.<br>
&gt;<br>
&gt; print works because &quot;hello&quot; :: (IsString a, Show a) =&gt; a<br>
&gt;<br>
&gt; knows nothing about the argument a<br>
&gt;<br>
&gt; and Show is included in the EDR list of blessed classes.<br>
&gt;<br>
&gt; If at the repl you turn on OverloadedStrings and EDR<br>
&gt;<br>
&gt; showList &quot;hello&quot; &quot;&quot;<br>
&gt;<br>
&gt; will still blow up, because it can know you have an argument [a] with a<br>
&gt; Show a constraint on it, and IsString [a], so it fails to meet the<br>
&gt; fairly simplistic conditions required by EDR.<br>
&gt;<br>
&gt; -Edward<br>
&gt;<br>
&gt;<br>
&gt; On Mon, Aug 26, 2013 at 4:34 PM, Dag Odenhall &lt;<a href="mailto:dag.odenhall@gmail.com">dag.odenhall@gmail.com</a><br>
</div><div class="im">&gt; &lt;mailto:<a href="mailto:dag.odenhall@gmail.com">dag.odenhall@gmail.com</a>&gt;&gt; wrote:<br>
&gt;<br>
&gt;     |ExtendedDefaultRules| already provides this to some extent, for<br>
&gt;     example it makes |print &quot;hello&quot;| work without type information.<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;     On Mon, Aug 26, 2013 at 10:09 PM, Dan Burton<br>
</div><div class="im">&gt;     &lt;<a href="mailto:danburton.email@gmail.com">danburton.email@gmail.com</a> &lt;mailto:<a href="mailto:danburton.email@gmail.com">danburton.email@gmail.com</a>&gt;&gt; wrote:<br>
&gt;<br>
&gt;         Just to throw another curveball at this conversation, what about<br>
&gt;         a general, ad-hoc solution for &#39;typeclass defaults&#39;? The logic<br>
&gt;         goes like this: Is there an &quot;ambiguous type variable&quot; error due<br>
&gt;         to the use of the IsString typeclass? Try defaulting to the<br>
&gt;         String instance. If that doesn&#39;t work, try defaulting to Text.<br>
&gt;         Repeat for a finite, explicit list of instances. If none of<br>
&gt;         these defaults are successful, type error.<br>
&gt;<br>
&gt;         We have hard-coded this sort of behavior into the Num class. Why<br>
&gt;         not just provide this general capability for arbitrary classes?<br>
&gt;         Or at least hard-code it into IsString as well.<br>
&gt;<br>
&gt;         In the absence of this sort of solution, +1 to Edward&#39;s original<br>
&gt;         proposal.<br>
&gt;<br>
&gt;         The &quot;o&quot; proposal is not viable because the oft-needed parens<br>
&gt;         make it confusing and irritating to the new Haskeller.<br>
&gt;<br>
&gt;         -- Dan Burton<br>
&gt;<br>
&gt;<br>
&gt;         On Mon, Aug 26, 2013 at 12:41 PM, Henning Thielemann<br>
&gt;         &lt;<a href="mailto:lemming@henning-thielemann.de">lemming@henning-thielemann.de</a><br>
</div><div class="im">&gt;         &lt;mailto:<a href="mailto:lemming@henning-thielemann.de">lemming@henning-thielemann.de</a>&gt;&gt; wrote:<br>
&gt;<br>
&gt;<br>
&gt;             On Mon, 26 Aug 2013, Gabriel Gonzalez wrote:<br>
&gt;<br>
&gt;                 I&#39;m guessing this is sarcastic, but I just want to<br>
&gt;                 clarify what I understood Henning&#39;s proposal to be.<br>
&gt;                  He&#39;s not saying we should provide an `o` function in<br>
&gt;                 the standard library, but rather encourage users to<br>
&gt;                 define their own.<br>
&gt;<br>
&gt;<br>
&gt;             Yes. I would be ok if packages provide this function, but I<br>
&gt;             would urge programmers to import that explicitly.<br>
&gt;<br>
&gt;<br>
&gt;                  This one liner would take the place of the current line<br>
&gt;                 that they devote right now to `OverloadedStrings` .<br>
&gt;<br>
&gt;<br>
&gt;             right<br>
&gt;<br>
&gt;<br>
&gt;                 However, the analogy is still apt since the exact same<br>
&gt;                 line of reasoning applies to overloaded numeric<br>
&gt;                 literals where we currently rely on defaulting to solve<br>
&gt;                 this problem.<br>
&gt;<br>
&gt;<br>
&gt;             I always use -Wall and thus I am warned about when<br>
&gt;             defaulting takes place. Thus I am confident that I do not<br>
&gt;             rely on defaulting in my code.<br>
&gt;<br>
&gt;             _______________________________________________<br>
&gt;             Libraries mailing list<br>
</div>&gt;             <a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a> &lt;mailto:<a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a>&gt;<br>
<div class="im">&gt;             <a href="http://www.haskell.org/mailman/listinfo/libraries" target="_blank">http://www.haskell.org/mailman/listinfo/libraries</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;         _______________________________________________<br>
&gt;         Libraries mailing list<br>
</div>&gt;         <a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a> &lt;mailto:<a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a>&gt;<br>
<div class="im">&gt;         <a href="http://www.haskell.org/mailman/listinfo/libraries" target="_blank">http://www.haskell.org/mailman/listinfo/libraries</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;     _______________________________________________<br>
&gt;     Libraries mailing list<br>
</div>&gt;     <a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a> &lt;mailto:<a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a>&gt;<br>
<div class="HOEnZb"><div class="h5">&gt;     <a href="http://www.haskell.org/mailman/listinfo/libraries" target="_blank">http://www.haskell.org/mailman/listinfo/libraries</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Libraries mailing list<br>
&gt; <a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
&gt; <a href="http://www.haskell.org/mailman/listinfo/libraries" target="_blank">http://www.haskell.org/mailman/listinfo/libraries</a><br>
&gt;<br>
<br>
</div></div></blockquote></div><br></div>