HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

ModuleUnique-0.4.7.9Haskell2010

Data.List.UniqueUnsorted

Library provides functions to find unique and duplicate elements in the list. Unlike Unique or UniqueStrict modules this one uses Data.HashMap.Strict for calculation.

The elements in the list can be unsorted (do not have an instance of Ord class, but Hashable is needed). This implementation is good for ByteStrings.

  • 10 values
  • PackageUnique-0.4.7.9
  • Exports10
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceUniqueUnsorted.hs
valueisUnique :: (Hashable a, Eq a) => a -> [a] -> Maybe Bool
#

isUnique function is to check whether the given element is unique in the list or not.

It returns Nothing when the element does not present in the list. Examples:

isUnique 'f' "foo bar" == Just True
isUnique 'o' "foo bar" == Just False
isUnique '!' "foo bar" == Nothing

Since 0.4.7.2

valuerepeated :: (Hashable a, Eq a) => [a] -> [a]
#

repeated finds only the elements that are present more than once in the list. Example:

 repeated  "foo bar" == "o"
valueunique :: (Hashable a, Eq a) => [a] -> [a]
#

unique gets only unique elements, that do not have duplicates.

unique  "foo bar" == " abrf"
valueallUnique :: (Hashable a, Eq a) => [a] -> Bool
#

allUnique checks whether all elements of the list are unique

allUnique "foo bar" == False
allUnique ['a'..'z'] == True
allUnique [] == True (!)

Since 0.4.7.2

valuecount :: (Hashable a, Eq a) => [a] -> [(a, Int)]
#

count of each element in the list. Example:

count "This is the test line" == [(' ',4),('s',3),('T',1),('t',3),('e',3),('h',2),('i',3),('l',1),('n',1)]
valuecount_ :: (Hashable a, Eq a) => [a] -> [(a, Int)]
#

count_ of each elements in the list, it sorts by their number. Example:

 count_ "This is the test line" == [('n',1),('l',1),('T',1),('h',2),('i',3),('e',3),('t',3),('s',3),(' ',4)]
valueoccurrences :: (Hashable a, Eq a) => [a] -> [(Int, [a])]
#

occurrences like count or count_ but shows the list of elements that occur X times

occurrences "This is the test line" == [(1,"Tln"),(2,"h"),(3,"eist"),(4," ")]

Since 0.4.7.5