Deprecate Foldable for Either

Andreas Abel andreas.abel at ifi.lmu.de
Thu Mar 2 18:56:27 UTC 2017


 > a whole universe of nicely polymorphic functions unavailable for them to
 > use without additional effort.

At least in terms of Either, I do not see a "universe of nicely 
polymorphic functions" here.  I'd say applying a Foldable on a complex 
data structure build of all sorts of type constructors that involve 
Either (and tuples) is highly counterintuitive.

For a start, the "sums-of-products" representation of data types is not 
stable under our Foldable instances.

   data D a
     = C1 a
     | C2 a a
     deriving (Foldable)

gives you a completely different Foldable instance than its 
sums-of-product representation

   Either a (a, a)

Andreas

On 02.03.2017 19:12, Kris Nuttycombe wrote:
> As with all of these discussions, the point of having Either be Foldable
> is not that you're going to call foldMap on an Either value directly.
> Instead, it is that you be able to pass whatever sort of foldable thing
> you choose (which Either certainly is) to a function that only requires
> foldability of its input. By removing or damaging the Foldable instance
> for Either, you don't simply prevent people from encountering problems
> that will be resolved the first time they test their software - you make
> a whole universe of nicely polymorphic functions unavailable for them to
> use without additional effort.
>
> In particular, the idea that one should make all such functions partial
> by throwing an error is repugnant.
>
> Kris
>
> On Thu, Mar 2, 2017 at 10:35 AM, Francesco Ariis <fa-ml at ariis.it
> <mailto:fa-ml at ariis.it>> wrote:
>
>     On Thu, Mar 02, 2017 at 05:19:26PM +0000, Oliver Charles wrote:
>     > Personally, I think it would be a shame to lose foldMap on EIther. I
>     > frequently foldMap over Maybe values (where mempty is suitable in case of
>     > "failure"), and I can certainly see myself doing the same thing with Either.
>
>     I am not trying to be polemic, just to see where the community
>     stands: regarding Either/Maybe: do you have use cases for length
>     (sum) too?
>
>     _______________________________________________
>     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>
>
>
>
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> 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/


More information about the Libraries mailing list