Bifoldable instance for Map

David Feuer david.feuer at
Mon Jun 1 12:27:51 UTC 2020

Let me be more specific. Whereas we can get intuition for Foldable from

    toList :: t a -> [a]

we get intuition for Bifoldable from the hypothetical

    toEitherList :: t a b -> [Either a b]

This seems quite reasonable for some types.

    data Loost a b
      = Nool
      | Corns b (Loost a b)
      | Colns a (Loost a b)

But for something like

    newtype Plist a b
      = PNil
      | PCons a b (PList a b)

it feels awfully strange. Independent parts of the structure just get
lumped together.

On Sat, May 30, 2020, 8:33 PM David Feuer <david.feuer at> wrote:

> Let me take that back. I forgot how weird Bifoldable and Bitraversable are
> for product types and product-like types. Is this instance actually useful
> for anything, or is it mostly confusing?
> On Mon, Apr 13, 2020, 9:46 PM David Feuer <david.feuer at> wrote:
>> I would go as far as to say we don't need to continue the proposal
>> process here. We're doing it.
>> On Mon, Apr 13, 2020, 9:44 PM David Feuer <david.feuer at> wrote:
>>> This seems eminently reasonable to me. We must also be sure to add one
>>> to Data.HashMap if that's missing too.
>>> On Mon, Apr 13, 2020, 9:36 PM Joseph C. Sible <josephcsible at>
>>> wrote:
>>>> I'd like to propose a change to the containers package: adding a
>>>> Bifoldable instance to Map. I briefly mentioned this on Reddit [1] and
>>>> no obvious problems were brought up. I submitted a PR implementing it
>>>> [2]. This seems like an obvious and straightforward instance to me.
>>>> Thoughts?
>>>> Joseph C. Sible
>>>> [1]:
>>>> [2]:
>>>> _______________________________________________
>>>> Libraries mailing list
>>>> Libraries at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Libraries mailing list