Aelve Codesearch

grep over package repositories
Please provide a string to search for.
3+ characters are required.
Index updated about a month ago

total matches: 6

universum-1.5.0
3 matches
src/Universum/Nub.hs

 * 'hashNub' is the fastest with 'Data.Text.Text'.

 * 'sortNub' has better performance than 'ordNub' but should be used when sorting is also needed.

 * 'unstableNub' has better performance than 'hashNub' but doesn't save the original order.
-}

module Universum.Nub

            
src/Universum/Nub.hs
module Universum.Nub
       ( hashNub
       , ordNub
       , sortNub
       , unstableNub
       ) where

import Data.Eq (Eq)
import Data.Hashable (Hashable)

            
src/Universum/Nub.hs

-- | Like 'ordNub' but also sorts a list.
--
-- >>> sortNub [3, 3, 3, 2, 2, -1, 1]
-- [-1,1,2,3]
{-@ sortNub :: [a] -> ListUnique a @-}
sortNub :: (Ord a) => [a] -> [a]
sortNub = Set.toList . Set.fromList

-- | Like 'hashNub' but has better performance and also doesn't save the order.
--
-- >>> unstableNub [3, 3, 3, 2, 2, -1, 1]
-- [1,2,3,-1]