
No idea. Traversing in a Biapplicative can definitely be interesting. I
don't know what Bifoldable or Bitraversable can do.
On Tue, Jun 2, 2020, 12:12 AM Joseph C. Sible
Let me turn this around: do you believe the Bifoldable class is a useful abstraction at all? Are there any real types (i.e., that exist in `base` or some other popular library or program, rather than made up for the sake of example) that you think have a useful Bifoldable instance? In other words, is your issue actually with this instance, or is it really with the entire class?
Joseph C. Sible
On Mon, Jun 1, 2020 at 5:51 PM David Feuer
wrote: 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
wrote:
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.