Deprecate Foldable for Either

amindfv at gmail.com amindfv at gmail.com
Mon Mar 20 00:30:34 UTC 2017



> El 19 mar 2017, a las 17:19, Tony Morris <tmorris at tmorris.net> escribió:
> 
> That you can't should be a hint that length for ((,) a) is very definitely 1.
> 

To be frank, this seems like a non-sequitur. Many of us find e.g.:

length (_, _) = 1
maximum (_, b) = b

to be dangerous instances. We don't want to accidentally call them. We'd like a way to opt out or warn on use.

The inability to opt out or be warned does not seem to me to be an argument that the above instances are good instances.

Feel free to clarify if I haven't understood your point.

Thanks!
Tom


> Simply, use a different function, not length, which is well-defined for ((,) a) and other instances.
> 
>> On Mon, Mar 20, 2017 at 3:15 AM, <amindfv at gmail.com> wrote:
>> Is there a clear way to implement this instance warning? I.e. given:
>> 
>> f x = 2 * length x
>> 
>> Can we guarantee at compile time that "f" will never be passed a 2-tuple?
>> 
>> Tom
>> 
>>> El 18 mar 2017, a las 20:04, Adam Bergmark <adam at bergmark.nl> escribió:
>>> 
>>> 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.
>>> 
>>> 
>>> 
>>>> On Sun, 19 Mar 2017 at 00:51 <amindfv at gmail.com> wrote:
>>>> 
>>>> 
>>>> > El 18 mar 2017, a las 16:01, Lana Black <lanablack at amok.cc> escribió:
>>>> >
>>>> >> On 18/03/17 19:49, Henning Thielemann wrote:
>>>> >>
>>>> >>> On Sat, 18 Mar 2017, Carter Schonwald wrote:
>>>> >>>
>>>> >>> for what?
>>>> >>
>>>> >> A warning if someone e.g. calls 'length (a,b)', or more generally, if
>>>> >> certain instances are used.
>>>> >> _______________________________________________
>>>> >> Libraries mailing list
>>>> >> Libraries at haskell.org
>>>> >> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>>> >
>>>> > Please no. Many of us like our code Wall-clean while still being able to
>>>> > write polymorphic functions. Adding more warnings that are often
>>>> > triggered by correct code (redundant constraints, anyone?) only leads to
>>>> > more headache.
>>>> >
>>>> > You could make that an hlint rule on the other hand.
>>>> 
>>>> 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.
>>>> 
>>>> I would also favor a warning, and happily have -Wall not include it (though I'd prefer inclusion).
>>>> 
>>>> Tom
>>>> 
>>>> 
>>>> > _______________________________________________
>>>> > Libraries mailing list
>>>> > Libraries at haskell.org
>>>> > http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>>> _______________________________________________
>>>> Libraries mailing list
>>>> Libraries at haskell.org
>>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>> 
>> _______________________________________________
>> Libraries mailing list
>> Libraries at haskell.org
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20170319/2c3bfbe4/attachment.html>


More information about the Libraries mailing list