Deprecate Foldable for Either

David Menendez dave at
Fri Mar 3 22:04:23 UTC 2017

On Thu, Mar 2, 2017 at 1:12 PM, Kris Nuttycombe <kris.nuttycombe at>

> 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.

Not just polymorphic functions. Many higher-order type constructors have
Foldable instances based on their parameters. For example,

data Cofree f a = a :< f (Cofree f a)

instance Foldable f => Foldable (Cofree f a) where
foldMap f (a :< as) = f a <> foldMap (foldMap f) as

Without the instance for Either b, we lose the instances for Cofree (Either
b) and Cofree (Compose [] (Either b)), both of which seem reasonable and

In particular, the idea that one should make all such functions partial by
> throwing an error is repugnant.

Yes, that seems like the worst possible solution. Better would be some way
to give a warning when calling an overloaded function at a particular type.

Dave Menendez <dave at>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Libraries mailing list