HORIZON HASKELLDocslts/ghc-10.0.x8174fa42026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8174fa4 · 2026-10-11

ModuleAgda-2.8.0.2Haskell2010

Agda.Utils.VarSet

Manage sets of natural numbers (de Bruijn indices).

  • 1 type
  • 20 values
  • PackageAgda-2.8.0.2
  • Exports21
  • LanguageHaskell2010
  • LicenceMIT
  • SourceVarSet.hs
valueinsert :: Key -> IntSet -> IntSet
#

O(\min(n,W)). Add a value to the set. There is no left- or right bias for IntSets.

valuefromList :: [Key] -> IntSet
#

O(n \min(n,W)). Create a set from a list of integers.

valuetoList :: IntSet -> [Key]
#

O(n). Convert the set to a list of elements. Subject to list fusion.

valuetoAscList :: IntSet -> [Key]
#

O(n). Convert the set to an ascending list of elements. Subject to list fusion.

valuetoDescList :: IntSet -> [Key]
#

O(n). Convert the set to a descending list of elements. Subject to list fusion.

valuedisjoint :: IntSet -> IntSet -> Bool
#

O(\min(n, m \log \frac{2^W}{m})), m \leq n. Check whether two sets are disjoint (i.e. their intersection is empty).

disjoint (fromList [2,4,6])   (fromList [1,3])     == True
disjoint (fromList [2,4,6,8]) (fromList [2,3,5,7]) == False
disjoint (fromList [1,2])     (fromList [1,2,3,4]) == False
disjoint (fromList [])        (fromList [])        == True
valueisSubsetOf :: IntSet -> IntSet -> Bool
#

O(\min(n, m \log \frac{2^W}{m})), m \leq n. Is this a subset? (s1 `isSubsetOf` s2) tells whether s1 is a subset of s2.

valuedelete :: Key -> IntSet -> IntSet
#

O(\min(n,W)). Delete a value in the set. Returns the original set when the value was not present.

valuemapMonotonic :: (Key -> Key) -> IntSet -> IntSet
#

O(n). The

mapMonotonic f s == map f s, but works only when f is strictly increasing. Semi-formally, we have:

and [x < y ==> f x < f y | x <- ls, y <- ls]
                    ==> mapMonotonic f s == map f s
    where ls = toList s

Warning: This function should be used only if f is monotonically strictly increasing. This precondition is not checked. Use map if the precondition may not hold.