HORIZON HASKELLDocslts/ghc-10.0.x77a86622026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 77a8662 · 2026-10-31

Modulehashmap-1.3.3Haskell98

Data.HashSet

Persistent Set based on hashing, which is defined as

  data Set e = Data.IntMap.IntMap (Some e)

is an Data.IntMap.IntMap indexed by hash values of elements, containing a value of Some e. That contains either one e or a Set e with elements of the same hash values.

The interface of a Set is a suitable subset of IntSet and can be used as a drop-in replacement of Set.

The complexity of operations is determined by the complexities of Data.IntMap.IntMap and Set operations. See the sources of Set to see which operations from containers package are used.

Contents
  1. Operators
  2. Query
  3. Construction
  4. Combine
  5. Filter
  6. Map
  7. Fold
  8. Conversion
Synopsis
  • Packagehashmap-1.3.3
  • Exports24
  • LanguageHaskell98
  • LicenceBSD-3-Clause
  • SourceHashSet.hs
newtypenewtype Set a

The abstract type of a Set. Its interface is a suitable subset of IntSet.

Instances8Eq, Data, Ord, Read, Show, Semigroup, …
typetype HashSet a = Set a

Deprecated. HashSet is deprecated. Please use Set instead.

The HashSet is a type synonym for Set for backward compatibility. It is deprecated and will be removed in furture releases.

Operators

Query

Construction

valueinsert :: (Hashable a, Ord a) => a -> Set a -> Set a

Add a value to the set. When the value is already an element of the set, it is replaced by the new one, ie. insert is left-biased.

valuedelete :: (Hashable a, Ord a) => a -> Set a -> Set a

Delete a value in the set. Returns the original set when the value was not present.

Combine

Filter

valuepartition :: Ord a => (a -> Bool) -> Set a -> (Set a, Set a)

Partition the set according to some predicate. The first set contains all elements that satisfy the predicate, the second all elements that fail the predicate.

Map

valuemap :: (Hashable b, Ord b) => (a -> b) -> Set a -> Set b

map f s is the set obtained by applying f to each element of s.

It's worth noting that the size of the result may be smaller if, for some (x,y), x /= y && f x == f y

Fold

valuefold :: (a -> b -> b) -> b -> Set a -> b

Fold over the elements of a set in an unspecified order.

Conversion

valueelems :: Set a -> [a]

The elements of a set. (For sets, this is equivalent to toList).