
30 Jan
2022
30 Jan
'22
3:54 a.m.
On Sat, Jan 29, 2022 at 07:25:16PM -0500, Viktor Dukhovni wrote:
it was observed that a similar approach can be used to give Data.Set a performant `elem` method
But why? It is impossible to program polymorphically in a meaningful way with Foldable, because Foldable has no coherent operational semantics. We discussed this at: https://github.com/haskell/core-libraries-committee/issues/20 If we could "improve" Set's `elem` instance what would that gain us? That we could write a Foldable-polymorphic function that works well on Set and badly on []? Then wy not just specialise to Set in the first place? Trying to "improve" Foldable instances seems like a fool's errand to me, especially if it trades off simplicity somewhere else. Tom