Faster `elem` "Hack" for Data.Set?

Tom Ellis tom-lists-haskell-cafe-2017 at
Sun Jan 30 08:54:35 UTC 2022

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:

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.


More information about the Libraries mailing list