Deprecate Foldable for Either

Edward Kmett ekmett at gmail.com
Thu Mar 2 19:28:17 UTC 2017


The nice thing about such a module is anybody can package it up. It needs
nothing special from base. During the discussion about Foldable, the option
to add a Data.List.Explicit or something that contained just the
monomorphic variants was brought up as something we could add, but nobody
really got enthusiastic over the idea.

The state of Data.List today is a messy intermediate state:

https://ghc.haskell.org/trac/ghc/wiki/Prelude710/FTP#list

When and if we get a resolution to
https://ghc.haskell.org/trac/ghc/ticket/4879 we're likely to proceed with
option 1 from that FTP page, which will at least avoid Data.List.concat
having the too general type, by dint of it no longer existing.

-Edward

On Thu, Mar 2, 2017 at 2:17 PM, Andreas Abel <andreas.abel at ifi.lmu.de>
wrote:

> We could have a module
>
>   Data.List.ReallyJustListsAndNotSomeThingMoreGeneric
>
> which implements concat and friends just for lists and could be imported
> if one wants to have the list operations.  Currently,
>
>   import qualified Data.List as List
>
> does not give on the list operations as e.g.
>
>   List.concat
>
> but the generic ones.
>
> See also http://ghc.haskell.org/trac/ghc/ticket/13345
>
> On 02.03.2017 20:02, Edward Kmett wrote:
>
>>
>> On Thu, Mar 2, 2017 at 11:59 AM, Andreas Abel <andreas.abel at ifi.lmu.de
>> <mailto:andreas.abel at ifi.lmu.de>> wrote:
>>
>>     Ok, Foldable is a formal condition for Traversable, but not actually
>>     used in the implementation of Traversable Either.  This still leaves
>>     room to implement Foldable for Either by
>>
>>       instance Foldable (Either a) where
>>         foldMap _ _ = error "Folding Either?  Naah, I don't think this
>>     is a good idea."
>>
>>
>> This would change the semantic of every
>>
>> forM_ myeither $ \i -> ....
>>
>> in existing code to silent errors.
>>
>> Hell no.
>>
>> -Edward
>>
>>
>>     On 02.03.2017 17:48, David Feuer wrote:
>>
>>         The problem is that we'd then lose the perfectly good Traversable
>>         instance, which would be sad.
>>
>>         On Mar 2, 2017 11:23 AM, "Andreas Abel" <andreas.abel at ifi.lmu.de
>>         <mailto:andreas.abel at ifi.lmu.de>
>>         <mailto:andreas.abel at ifi.lmu.de
>>
>>         <mailto:andreas.abel at ifi.lmu.de>>> wrote:
>>
>>             Today a student came to me wondering why a certain function
>>         produced
>>             a regular result, where he had expected an error.  Turned
>>         out he had
>>             used `concat`, but not on a lists of lists as he had
>>         thought, but on
>>             a lists of `Either a [b]`.
>>
>>             With the Foldable instance for Either, which considers
>>         Either a b to
>>             be a container of 0-1 elements of b, errors are happily
>>         swallowed.
>>
>>             I think this instance is harmful and should be deprecated
>>         (and later
>>             removed) from base.
>>
>>             There are similarly pointless Foldable instances as well.
>>
>>             See a discussion one year ago, which was heated, but had no
>>             consequences.
>>
>>
>>         https://mail.haskell.org/pipermail/libraries/2016-February/
>> 026678.html
>>         <https://mail.haskell.org/pipermail/libraries/2016-February/
>> 026678.html>
>>
>>         <https://mail.haskell.org/pipermail/libraries/2016-February/
>> 026678.html
>>         <https://mail.haskell.org/pipermail/libraries/2016-February/
>> 026678.html>>
>>
>>
>>             --
>>             Andreas Abel  <><      Du bist der geliebte Mensch.
>>
>>             Department of Computer Science and Engineering
>>             Chalmers and Gothenburg University, Sweden
>>
>>             andreas.abel at gu.se <mailto:andreas.abel at gu.se>
>>         <mailto:andreas.abel at gu.se <mailto:andreas.abel at gu.se>>
>>             http://www.cse.chalmers.se/~abela/
>>         <http://www.cse.chalmers.se/~abela/>
>>         <http://www.cse.chalmers.se/~abela/
>>         <http://www.cse.chalmers.se/~abela/>>
>>             _______________________________________________
>>             Libraries mailing list
>>             Libraries at haskell.org <mailto:Libraries at haskell.org>
>>         <mailto:Libraries at haskell.org <mailto:Libraries at haskell.org>>
>>             http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>         <http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries>
>>             <http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>         <http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries>>
>>
>>
>>
>>     --
>>     Andreas Abel  <><      Du bist der geliebte Mensch.
>>
>>     Department of Computer Science and Engineering
>>     Chalmers and Gothenburg University, Sweden
>>
>>     andreas.abel at gu.se <mailto:andreas.abel at gu.se>
>>     http://www.cse.chalmers.se/~abela/ <http://www.cse.chalmers.se/~a
>> bela/>
>>     _______________________________________________
>>     Libraries mailing list
>>     Libraries at haskell.org <mailto:Libraries at haskell.org>
>>     http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>     <http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries>
>>
>>
>>
>
> --
> Andreas Abel  <><      Du bist der geliebte Mensch.
>
> Department of Computer Science and Engineering
> Chalmers and Gothenburg University, Sweden
>
> andreas.abel at gu.se
> http://www.cse.chalmers.se/~abela/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20170302/47d6c399/attachment.html>


More information about the Libraries mailing list