Safe Haskell | None |
---|---|

Language | Haskell2010 |

## Synopsis

- data Set a
- singleton :: PrimUnlifted a => a -> Set a
- member :: (PrimUnlifted a, Ord a) => a -> Set a -> Bool
- size :: PrimUnlifted a => Set a -> Int
- toArray :: Set a -> UnliftedArray a
- toList :: PrimUnlifted a => Set a -> [a]
- fromNonEmpty :: (PrimUnlifted a, Ord a) => NonEmpty a -> Set a
- toSet :: Set a -> Set a
- fromSet :: Set a -> Maybe (Set a)
- foldr :: PrimUnlifted a => (a -> b -> b) -> b -> Set a -> b
- foldMap :: (PrimUnlifted a, Monoid m) => (a -> m) -> Set a -> m
- foldl' :: PrimUnlifted a => (b -> a -> b) -> b -> Set a -> b
- foldr' :: PrimUnlifted a => (a -> b -> b) -> b -> Set a -> b
- foldMap' :: (PrimUnlifted a, Monoid m) => (a -> m) -> Set a -> m
- traverse_ :: (Applicative m, PrimUnlifted a) => (a -> m b) -> Set a -> m ()
- itraverse_ :: (Applicative m, PrimUnlifted a) => (Int -> a -> m b) -> Set a -> m ()

# Documentation

## Instances

(PrimUnlifted a, Eq a) => Eq (Set a) Source # | |

(PrimUnlifted a, Ord a) => Ord (Set a) Source # | |

(PrimUnlifted a, Show a) => Show (Set a) Source # | |

(Ord a, PrimUnlifted a) => Semigroup (Set a) Source # | |

(Hashable a, PrimUnlifted a) => Hashable (Set a) Source # | |

Defined in Data.Set.NonEmpty.Unlifted |

singleton :: PrimUnlifted a => a -> Set a Source #

Construct a set with a single element.

# Conversion

toArray :: Set a -> UnliftedArray a Source #

*O(1)* Convert a set to an array. The elements are given in ascending
order. This function is zero-cost.

toList :: PrimUnlifted a => Set a -> [a] Source #

*O(n)* Convert a set to a list. The elements are given in ascending order.

fromNonEmpty :: (PrimUnlifted a, Ord a) => NonEmpty a -> Set a Source #

*O(n*log n)* Convert a list to a set.

toSet :: Set a -> Set a Source #

*O(0)* Convert a non-empty set to a set. The resulting set shares
the internal representation with the argument.

fromSet :: Set a -> Maybe (Set a) Source #

*O(1)* Convert a set to a non-empty set. This returns `Nothing`

if
the set is empty. The resulting non-empty set shares internal
represention as the argument.

# Folds

foldr :: PrimUnlifted a => (a -> b -> b) -> b -> Set a -> b Source #

Right fold over the elements in the set. This is lazy in the accumulator.

foldMap :: (PrimUnlifted a, Monoid m) => (a -> m) -> Set a -> m Source #

Monoidal fold over the elements in the set. This is lazy in the accumulator.

foldl' :: PrimUnlifted a => (b -> a -> b) -> b -> Set a -> b Source #

Strict left fold over the elements in the set.

foldr' :: PrimUnlifted a => (a -> b -> b) -> b -> Set a -> b Source #

Strict right fold over the elements in the set.

foldMap' :: (PrimUnlifted a, Monoid m) => (a -> m) -> Set a -> m Source #

Strict monoidal fold over the elements in the set.

# Traversals

traverse_ :: (Applicative m, PrimUnlifted a) => (a -> m b) -> Set a -> m () Source #

Traverse a set, discarding the result.

itraverse_ :: (Applicative m, PrimUnlifted a) => (Int -> a -> m b) -> Set a -> m () Source #

Traverse a set with the indices, discarding the result.