Proposal: add ordNub somewhere in containers

Michael Walker mike at
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
( 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 (

More information about the Libraries mailing list