<div dir="ltr"><div>That you can't should be a hint that length for ((,) a) is very definitely 1.<br><br></div>Simply, use a different function, not length, which is well-defined for ((,) a) and other instances.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 20, 2017 at 3:15 AM, <span dir="ltr"><<a href="mailto:amindfv@gmail.com" target="_blank">amindfv@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div></div><div>Is there a clear way to implement this instance warning? I.e. given:</div><div><br></div><div>f x = 2 * length x</div><div><br></div><div>Can we guarantee at compile time that "f" will never be passed a 2-tuple?</div><div><br></div><div>Tom</div><div><div class="h5"><div><br>El 18 mar 2017, a las 20:04, Adam Bergmark <<a href="mailto:adam@bergmark.nl" target="_blank">adam@bergmark.nl</a>> escribió:<br><br></div><blockquote type="cite"><div><div dir="ltr">I'm on the fence about the instance existing. I'm +1 for a warning, and thus would be +1 on keeping the instance. +1 on making the warning opt-in and +1 keeping it out of -Wall.<div><br><div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Sun, 19 Mar 2017 at 00:51 <<a href="mailto:amindfv@gmail.com" target="_blank">amindfv@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br class="m_-8946947274453652233gmail_msg">
<br class="m_-8946947274453652233gmail_msg">
> El 18 mar 2017, a las 16:01, Lana Black <<a href="mailto:lanablack@amok.cc" target="_blank">lanablack@amok.cc</a>> escribió:<br class="m_-8946947274453652233gmail_msg">
><br class="m_-8946947274453652233gmail_msg">
>> On 18/03/17 19:49, Henning Thielemann wrote:<br class="m_-8946947274453652233gmail_msg">
>><br class="m_-8946947274453652233gmail_msg">
>>> On Sat, 18 Mar 2017, Carter Schonwald wrote:<br class="m_-8946947274453652233gmail_msg">
>>><br class="m_-8946947274453652233gmail_msg">
>>> for what?<br class="m_-8946947274453652233gmail_msg">
>><br class="m_-8946947274453652233gmail_msg">
>> A warning if someone e.g. calls 'length (a,b)', or more generally, if<br class="m_-8946947274453652233gmail_msg">
>> certain instances are used.<br class="m_-8946947274453652233gmail_msg">
>> ______________________________<wbr>_________________<br class="m_-8946947274453652233gmail_msg">
>> Libraries mailing list<br class="m_-8946947274453652233gmail_msg">
>> <a href="mailto:Libraries@haskell.org" class="m_-8946947274453652233gmail_msg" target="_blank">Libraries@haskell.org</a><br class="m_-8946947274453652233gmail_msg">
>> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" class="m_-8946947274453652233gmail_msg" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/libraries</a><br class="m_-8946947274453652233gmail_msg">
><br class="m_-8946947274453652233gmail_msg">
> Please no. Many of us like our code Wall-clean while still being able to<br class="m_-8946947274453652233gmail_msg">
> write polymorphic functions. Adding more warnings that are often<br class="m_-8946947274453652233gmail_msg">
> triggered by correct code (redundant constraints, anyone?) only leads to<br class="m_-8946947274453652233gmail_msg">
> more headache.<br class="m_-8946947274453652233gmail_msg">
><br class="m_-8946947274453652233gmail_msg">
> You could make that an hlint rule on the other hand.<br class="m_-8946947274453652233gmail_msg">
<br class="m_-8946947274453652233gmail_msg">
Can it be a hlint rule? It seems quite difficult to predict that "length" will not ever be passed e.g. a 2-tuple in the general case, within hlint.<br class="m_-8946947274453652233gmail_msg">
<br class="m_-8946947274453652233gmail_msg">
I would also favor a warning, and happily have -Wall not include it (though I'd prefer inclusion).<br class="m_-8946947274453652233gmail_msg">
<br class="m_-8946947274453652233gmail_msg">
Tom<br class="m_-8946947274453652233gmail_msg">
<br class="m_-8946947274453652233gmail_msg">
<br class="m_-8946947274453652233gmail_msg">
> ______________________________<wbr>_________________<br class="m_-8946947274453652233gmail_msg">
> Libraries mailing list<br class="m_-8946947274453652233gmail_msg">
> <a href="mailto:Libraries@haskell.org" class="m_-8946947274453652233gmail_msg" target="_blank">Libraries@haskell.org</a><br class="m_-8946947274453652233gmail_msg">
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" class="m_-8946947274453652233gmail_msg" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/libraries</a><br class="m_-8946947274453652233gmail_msg">
______________________________<wbr>_________________<br class="m_-8946947274453652233gmail_msg">
Libraries mailing list<br class="m_-8946947274453652233gmail_msg">
<a href="mailto:Libraries@haskell.org" class="m_-8946947274453652233gmail_msg" target="_blank">Libraries@haskell.org</a><br class="m_-8946947274453652233gmail_msg">
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" class="m_-8946947274453652233gmail_msg" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/libraries</a><br class="m_-8946947274453652233gmail_msg">
</blockquote></div>
</div></blockquote></div></div></div><br>______________________________<wbr>_________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/libraries</a><br>
<br></blockquote></div><br></div>