
Yes, folding generally loses structure. This just seems especially
egregious. Can you think of even a single function polymorphic over
`Bifoldable` containers that you'd find it useful to pass a `HashMap`
to?
On Mon, Jun 1, 2020 at 5:34 PM Joseph C. Sible
Aren't you basically just saying that you lose some of the structure (namely, the knowledge that the "key" and its "value" go together)? But doesn't every Foldable instance on a type that's more complex than a list also do that? For example, if you fold a rose tree, you lose the knowledge of which elements came from which branches.
(Completely unrelated: "Loost" and the names of its data constructors sound like something straight from Dr. Seuss.)
Joseph C. Sible
On Mon, Jun 1, 2020 at 8:28 AM David Feuer
wrote: 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.