Why is there no Foldable instance for Either?
Shachaf Ben-Kiki
shachaf at gmail.com
Wed Jun 12 11:10:37 CEST 2013
On Thu, May 30, 2013 at 6:41 PM, Shachaf Ben-Kiki <shachaf at gmail.com> wrote:
> 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
Just to make sure this isn't slipping through the cracks -- is there a
particular reason not to add the instance for (Const r)? It was
brought up in the last discussion and it has one obviously-correct
definition. It's a useful instance.
(Right now, as mentioned, lens defines orphans for all three types --
it would be nice to get rid of all of them in one go.)
Thanks,
Shachaf
More information about the Libraries
mailing list