FR
importPour l'utiliser : import Data.Set

Set — ordered, immutable finite sets

Synopsis
empty : Set a

The empty set.

singleton : a -> Set a

A set with a single element.

isEmpty : Set a -> Bool

True if the set has no elements.

size : Set a -> Nat

The number of elements (O(1)).

member : Ord a => a -> Set a -> Bool

True if the element is in the set.

insert : Ord a => a -> Set a -> Set a

Insert an element (a no-op if already present).

delete : Ord a => a -> Set a -> Set a

Remove an element (a no-op if absent).

toList : Set a -> List a

The elements as a list, in ascending order.

fromList : Ord a => List a -> Set a

Build a set from a list (duplicates collapse).

union : Ord a => Set a -> Set a -> Set a

Union (all elements of either set).

intersection : Ord a => Set a -> Set a -> Set a

Intersection (elements in both sets).

difference : Ord a => Set a -> Set a -> Set a

Difference (elements of the first set not in the second).

isSubsetOf : Ord a => Set a -> Set a -> Bool

True if every element of the first set is in the second.

filter : Ord a => (a -> Bool) -> Set a -> Set a

Keep only the elements satisfying the predicate.

map : Ord b => (a -> b) -> Set a -> Set b

Map a function over the elements. Unlike Functor, this needs Ord on the result type (the image must be re-sorted and deduplicated), so Set is NOT a Functor — this is a plain function (as in Haskell's Data.Set).

foldr : (a -> b -> b) -> b -> Set a -> b

Fold over the elements in ascending order.

foldl : (b -> a -> b) -> b -> Set a -> b

Left fold over the elements in ascending order.