Functor, Applicative, Monad, Foldable, Traversable instances for (, , ) a b

Francesco Ariis fa-ml at ariis.it
Sun Apr 9 20:33:44 UTC 2017


On Sun, Apr 09, 2017 at 03:27:02PM -0500, amindfv at gmail.com wrote:
> Genuinely curious: can people point to specific examples in their (or
> others') code where the ((,) a) instance for Foldable is really helpful
> and difficult to replace?

I asked in the other thread, these are some of the answers I got:

Oliver Charles:
> Personally, I think it would be a shame to lose foldMap on EIther. I
> frequently foldMap over Maybe values (where mempty is suitable in case of
> "failure"), and I can certainly see myself doing the same thing with
> Either.

Oleg Grenrus:
> Anecdotally, today I wrote `foldMap toList`, to use as `Maybe (NonEmpty
> a) -> [a]`.
> Also I rely heavily in lens-based code on the `folded :: Fold (Maybe a)
> a`.

There haven't been replies on specific usage of functions length/sum/
maximum/etc.

I can't recall where, but someone else was making a point that a {-# Poison
something #-} pragma would fracture the ecosystem.
I don't think this holds much weight though, as library authors would most
likely toggle the flag in development (to avoid calling length Either,
etc.) and toggle it back on release.

-F


More information about the Libraries mailing list