WeakSets-1.2.4.0: Simple set types. Useful to create sets of arbitrary types and nested sets.
CopyrightGuillaume Sabbagh 2022
LicenseLGPL-3.0-or-later
Maintainerguillaumesabbagh@protonmail.com
Stabilityexperimental
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.WeakSet.Safe

Description

Non-clashing functions for Sets.

Synopsis

Documentation

set :: [a] -> Set a Source #

O(1). The smart constructor of sets. This is the only way of instantiating a Set with fromList.

We prefer the smart constructor set because its name does not collide with other data structures.

Set related functions

setToList :: Eq a => Set a -> [a] Source #

O(n^2). Transform a Set back into a list, the list returned does not have duplicate elements, the order of the original list holds.

isIncludedIn :: Eq a => Set a -> Set a -> Bool Source #

O(n^2). Return a boolean indicating if a Set is included in another one.

cardinal :: Eq a => Set a -> Int Source #

O(n^2). Size of a set.

isIn :: Eq a => a -> Set a -> Bool Source #

O(n). Return wether an element is in a set.

(|&|) :: Eq a => Set a -> Set a -> Set a Source #

Alias of intersection.

(|||) :: Set a -> Set a -> Set a Source #

Alias of union.

(|*|) :: Set a -> Set b -> Set (a, b) Source #

(|+|) :: Set a -> Set b -> Set (Either a b) Source #

Alias of disjointUnion.

(|-|) :: Eq a => Set a -> Set a -> Set a Source #

Alias of difference.

(|^|) :: Eq a => Set a -> Int -> Set [a] Source #

Returns the cartesian product of a set with itself n times.

nubSetBy :: (a -> a -> Bool) -> Set a -> [a] Source #

O(n^2). Remove duplicates in the set using your own equality function.

anElement :: Set a -> a Source #

O(1). Return an element of the set if it is not empty, throw an error otherwise.

cartesianProductOfSet :: Set (Set a) -> Set (Set a) Source #

Return the cartesian product of a set of set.