
17 Oct
2017
17 Oct
'17
5:41 a.m.
ordNub could be implemented using Traversable:
catMaybes (traverse ??? xs :: [Maybe a])
You would only need a generalization for catMaybes like mfilter.
The witherable package (https://hackage.haskell.org/package/witherable) has a typeclass generalising Traversable to containers which can remove elements. So I suspect Witherable is exactly the abstraction needed to write a polymorphic function: ordNub :: (Witherable f, Ord a) => f a -> f a ordNub = catMaybes . ordNub' ordNub' :: (Traversable f, Ord a) => f a -> f (Maybe a) ordNub; = ... -- Michael Walker (http://www.barrucadu.co.uk)