Proposal: add ordNub somewhere in containers
Michael Walker
mike at barrucadu.co.uk
Tue Oct 17 09:41:47 UTC 2017
> 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)
More information about the Libraries
mailing list