
28 Jul
2017
28 Jul
'17
2:42 a.m.
On Thu, 27 Jul 2017, David Feuer wrote:
The Foldable class offers the method
elem :: Eq a => a -> t a -> Bool
Unfortunately, this is really awful for sets, hash maps, etc. See https://stackoverflow.com/questions/45361801/implement-an-olog-n-foldable-el... for an example.
I'd prefer to keep Foldable Haskell-98. You may introduce methods with advanced types in a sub-class. I also think that the Set type does not perfectly fit to Foldable. Most Set methods require Ord constraint, but Set.toList does not. Only this allows to have instance Foldable Set. This looks to me like an implementation detail. E.g. for Vector.Storable this trick does not work. You cannot omit the Storable constraint in Vector.toList.