Why is there no Foldable instance for Either?

Shachaf Ben-Kiki shachaf at gmail.com
Fri May 31 03:41:14 CEST 2013


On Thu, May 30, 2013 at 6:34 PM, Ross Paterson <R.Paterson at city.ac.uk> wrote:
> On Thu, May 30, 2013 at 01:12:00PM -0700, Shachaf Ben-Kiki wrote:
>> This instance should exist. There's been a couple of discussion on
>> libraries@ before. One of them is at
>> <http://www.haskell.org/pipermail/libraries/2012-July/018246.html>.
>
> The previous one was in January 2011:
>
> http://thread.gmane.org/gmane.comp.lang.haskell.libraries/15196
>
> I've taken the liberty of pushing the previously discussed Foldable and
> Traversable instances for Either a and (,) a.
>

Thank you! While you're at it would it be possible to add (trivial)
Foldable and Traversable instances for (Const r), for completeness? I
think that was also mentioned in one of the discussions. As in my
patch, the instances are:

instance Foldable (Const m) where
    foldMap _ _ = mempty

instance Traversable (Const m) where
    traverse f (Const m) = pure (Const m)

    Shachaf



More information about the Libraries mailing list