Why is there no Foldable instance for Either?

Mario Blažević mblazevic at stilo.com
Mon Jun 3 15:59:25 CEST 2013


On 13-05-30 03:53 PM, Gabriel Gonzalez wrote:
> I'm surprised that `Either` does not have a `Foldable` instance of the
> form:
>
>      import Data.Foldable
>      import Data.Monoid
>
>      instance Foldable (Either e) where
>          foldMap f (Left  _) = mempty
>          foldMap f (Right r) = f r
>
>          foldr _ z (Left  _) = z
>          foldr f z (Right r) = f r z

+1 for adding it




More information about the Libraries mailing list