Set -package:dhall

Finite Sets

The Set e type represents a set of elements of type e. Most operations require that e be an instance of the Ord class. A Set is strict in its elements. For a walkthrough of the most commonly used functions see the sets introduction. This module is intended to be imported qualified, to avoid name clashes with Prelude functions, e.g.
import Data.Set (Set)
import qualified Data.Set as Set
Note that the implementation is generally left-biased. Functions that take two sets as arguments and combine them, such as union and intersection, prefer the entries in the first argument to those in the second. Of course, this bias can only be observed when equality is an equivalence relation instead of structural equality.

Warning

The size of the set must not exceed maxBound::Int. Violation of this condition is not detected and if the size limit is exceeded, its behaviour is undefined.

Implementation

The implementation of Set is based on size balanced binary trees (or trees of bounded balance) as described by: Bounds for union, intersection, and difference are as given by

Performance information

The time complexity is given for each operation in big-O notation, with <math> referring to the number of entries in the set. Operations like member, insert, and delete take <math> time. Binary set operations like union and intersection take <math> time, where <math> and <math> are the sizes of the smaller and larger input sets respectively.
A set of values a.
Invariant preserving version of Set from the containers packages, suitable for use with Uniplate. Use toSet to construct values, and fromSet to deconstruct values.
Set. Import as:
import qualified RIO.Set as Set
This module does not export any partial or unchecked functions. For those, see RIO.Set.Partial and RIO.Set.Unchecked
A hash set, based on an STM-specialized hash array mapped trie.
A set of values a.
TOML-specific combinators for converting between TOML and Haskell Set-like data types. There are two way to represent list-like structures with the tomland library.
  • Ordinary array sets of primitives:
    foo = [100, 200, 300]
    
  • Sets via tables:
    foo = [ {x = 100} , {x = 200} , {x = 300} ]
    OR [[foo]] x = 100 [[foo]] x = 200 [[foo]] x = 300 
You can find both types of the codecs in this module for different set-like structures. See the following table for the better understanding: TODO: table
Set the value to a new value.
Set its value to the provided one
Lists representing sets. The Listable tiers enumeration will not have repeated sets.
> take 6 (list :: [Set Nat])
[Set [],Set [0],Set [1],Set [0,1],Set [2],Set [0,2]]
A collection of set utilities, useful when working with symbolic sets. To the extent possible, the functions in this module follow those of Data.Set so importing qualified is the recommended workflow. Note that unlike Data.Set, SBV sets can be infinite, represented as a complement of some finite set. This means that a symbolic set is either finite, or its complement is finite. (If the underlying domain is finite, then obviously both the set itself and its complement will always be finite.) Therefore, there are some differences in the API from Haskell sets. For instance, you can take the complement of any set, which is something you cannot do in Haskell! Conversely, you cannot compute the size of a symbolic set (as it can be infinite!), nor you can turn it into a list or necessarily enumerate its elements.