>>> nub [1,2,3,4,3,2,1,2,4,3,5] [1,2,3,4,5]If the order of outputs does not matter and there exists instance Ord a, it's faster to use map Data.List.NonEmpty.head . Data.List.NonEmpty.group . sort, which takes only <math> time.
>>> ordNub [1,2,1] :: [Int] [1,2]
>>> ordNubRight [1,2,1] :: [Int] [2,1]