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

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.

  • 2 types
  • 22 values
  • 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

1 declaration

Query

6 declarations
valuesize :: Set a -> Int
#

Number of elements in the set.

Construction

4 declarations
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

4 declarations

Filter

2 declarations
valuefilter :: Ord a => (a -> Bool) -> Set a -> Set a
#

Filter all elements that satisfy some predicate.

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

1 declaration
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

1 declaration
valuefold :: (a -> b -> b) -> b -> Set a -> b
#

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

Conversion

3 declarations
valueelems :: Set a -> [a]
#

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

valuetoList :: Set a -> [a]
#

Convert the set to a list of elements.