Set -package:uniplate

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.
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
This module only exports ways of constructing a Set, retrieving List, Set, and Seq representations of the same data, as well as a novel "difference" function. Any other Set-like or List-like functionality should be obtained through toSet and toList, respectively.
This is a variation on Data.Set.Set that remembers the original order of elements. This ensures that ordering is not lost when formatting Dhall code
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]]