snoyberg / mono-traversable

Type classes for mapping, folding, and traversing monomorphic containers
152 stars 61 forks source link

Consider adding `instance MonoFunctor Set` #176

Open tysonzero opened 4 years ago

tysonzero commented 4 years ago

Thus, even though a MonoFunctor instance for Set could theoretically be defined, it is omitted since it could violate the functor law of omap f . omap g = omap (f . g).

The current docs in Data.Eq specifies that Eq is expected to follow the substitutivity law (modulo private functions, such as showTree and friends), so this functor law could only be violated via an unlawful instance.

Since it is well established that laws are not expected to hold in the presence of law violating instances (Foldable for Set onto a non-associative Monoid violates laws for example), I think it's worth considering adding this instance.

snoyberg commented 4 years ago

I don't have any strong thoughts on this to be honest.