Safe Haskell  SafeInferred 

Language  Haskell2010 
Set
with hashed members. Import as:
import qualified RIO.HashSet as HS
Synopsis
 data HashSet a
 empty :: HashSet a
 singleton :: Hashable a => a > HashSet a
 union :: (Eq a, Hashable a) => HashSet a > HashSet a > HashSet a
 unions :: (Eq a, Hashable a) => [HashSet a] > HashSet a
 null :: HashSet a > Bool
 size :: HashSet a > Int
 member :: (Eq a, Hashable a) => a > HashSet a > Bool
 insert :: (Eq a, Hashable a) => a > HashSet a > HashSet a
 delete :: (Eq a, Hashable a) => a > HashSet a > HashSet a
 map :: (Hashable b, Eq b) => (a > b) > HashSet a > HashSet b
 difference :: (Eq a, Hashable a) => HashSet a > HashSet a > HashSet a
 intersection :: (Eq a, Hashable a) => HashSet a > HashSet a > HashSet a
 foldl' :: (a > b > a) > a > HashSet b > a
 foldr :: (b > a > a) > a > HashSet b > a
 filter :: (a > Bool) > HashSet a > HashSet a
 toList :: HashSet a > [a]
 fromList :: (Eq a, Hashable a) => [a] > HashSet a
 toMap :: HashSet a > HashMap a ()
 fromMap :: HashMap a () > HashSet a
Documentation
A set of values. A set cannot contain duplicate values.
Instances
Foldable HashSet  
Defined in Data.HashSet.Internal fold :: Monoid m => HashSet m > m # foldMap :: Monoid m => (a > m) > HashSet a > m # foldMap' :: Monoid m => (a > m) > HashSet a > m # foldr :: (a > b > b) > b > HashSet a > b # foldr' :: (a > b > b) > b > HashSet a > b # foldl :: (b > a > b) > b > HashSet a > b # foldl' :: (b > a > b) > b > HashSet a > b # foldr1 :: (a > a > a) > HashSet a > a # foldl1 :: (a > a > a) > HashSet a > a # elem :: Eq a => a > HashSet a > Bool # maximum :: Ord a => HashSet a > a # minimum :: Ord a => HashSet a > a #  
Eq1 HashSet  
Ord1 HashSet  
Defined in Data.HashSet.Internal  
Show1 HashSet  
NFData1 HashSet  Since: unorderedcontainers0.2.14.0 
Defined in Data.HashSet.Internal  
Hashable1 HashSet  
Defined in Data.HashSet.Internal  
(Eq a, Hashable a) => IsList (HashSet a)  
Eq a => Eq (HashSet a)  Note that, in the presence of hash collisions, equal
In general, the lack of substitutivity can be observed with any function that depends on the key ordering, such as folds and traversals. 
(Data a, Eq a, Hashable a) => Data (HashSet a)  
Defined in Data.HashSet.Internal gfoldl :: (forall d b. Data d => c (d > b) > d > c b) > (forall g. g > c g) > HashSet a > c (HashSet a) # gunfold :: (forall b r. Data b => c (b > r) > c r) > (forall r. r > c r) > Constr > c (HashSet a) # toConstr :: HashSet a > Constr # dataTypeOf :: HashSet a > DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) > Maybe (c (HashSet a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) > Maybe (c (HashSet a)) # gmapT :: (forall b. Data b => b > b) > HashSet a > HashSet a # gmapQl :: (r > r' > r) > r > (forall d. Data d => d > r') > HashSet a > r # gmapQr :: forall r r'. (r' > r > r) > r > (forall d. Data d => d > r') > HashSet a > r # gmapQ :: (forall d. Data d => d > u) > HashSet a > [u] # gmapQi :: Int > (forall d. Data d => d > u) > HashSet a > u # gmapM :: Monad m => (forall d. Data d => d > m d) > HashSet a > m (HashSet a) # gmapMp :: MonadPlus m => (forall d. Data d => d > m d) > HashSet a > m (HashSet a) # gmapMo :: MonadPlus m => (forall d. Data d => d > m d) > HashSet a > m (HashSet a) #  
Ord a => Ord (HashSet a)  
Defined in Data.HashSet.Internal  
(Eq a, Hashable a, Read a) => Read (HashSet a)  
Show a => Show (HashSet a)  
(Hashable a, Eq a) => Semigroup (HashSet a)  O(n+m) To obtain good performance, the smaller set must be presented as the first argument. Examples

(Hashable a, Eq a) => Monoid (HashSet a)  O(n+m) To obtain good performance, the smaller set must be presented as the first argument. Examples

NFData a => NFData (HashSet a)  
Defined in Data.HashSet.Internal  
Hashable a => Hashable (HashSet a)  
Defined in Data.HashSet.Internal  
type Item (HashSet a)  
Defined in Data.HashSet.Internal 
Construction
singleton :: Hashable a => a > HashSet a #
O(1) Construct a set with a single element.
>>>
HashSet.singleton 1
fromList [1]
Combine
union :: (Eq a, Hashable a) => HashSet a > HashSet a > HashSet a #
O(n+m) Construct a set containing all elements from both sets.
To obtain good performance, the smaller set must be presented as the first argument.
>>>
union (fromList [1,2]) (fromList [2,3])
fromList [1,2,3]
unions :: (Eq a, Hashable a) => [HashSet a] > HashSet a #
Construct a set containing all elements from a list of sets.
Basic interface
O(n) Return the number of elements in this set.
>>>
HashSet.size HashSet.empty
0>>>
HashSet.size (HashSet.fromList [1,2,3])
3
insert :: (Eq a, Hashable a) => a > HashSet a > HashSet a #
O(log n) Add the specified value to this set.
>>>
HashSet.insert 1 HashSet.empty
fromList [1]
delete :: (Eq a, Hashable a) => a > HashSet a > HashSet a #
O(log n) Remove the specified value from this set if present.
>>>
HashSet.delete 1 (HashSet.fromList [1,2,3])
fromList [2,3]>>>
HashSet.delete 1 (HashSet.fromList [4,5,6])
fromList [4,5,6]
Transformations
map :: (Hashable b, Eq b) => (a > b) > HashSet a > HashSet b #
O(n) Transform this set by applying a function to every value. The resulting set may be smaller than the source.
>>>
HashSet.map show (HashSet.fromList [1,2,3])
HashSet.fromList ["1","2","3"]
Difference and intersection
difference :: (Eq a, Hashable a) => HashSet a > HashSet a > HashSet a #
O(n) Difference of two sets. Return elements of the first set not existing in the second.
>>>
HashSet.difference (HashSet.fromList [1,2,3]) (HashSet.fromList [2,3,4])
fromList [1]
intersection :: (Eq a, Hashable a) => HashSet a > HashSet a > HashSet a #
O(n) Intersection of two sets. Return elements present in both the first set and the second.
>>>
HashSet.intersection (HashSet.fromList [1,2,3]) (HashSet.fromList [2,3,4])
fromList [2,3]
Folds
foldl' :: (a > b > a) > a > HashSet b > a #
O(n) Reduce this set by applying a binary operator to all elements, using the given starting value (typically the leftidentity of the operator). Each application of the operator is evaluated before before using the result in the next application. This function is strict in the starting value.
foldr :: (b > a > a) > a > HashSet b > a #
O(n) Reduce this set by applying a binary operator to all elements, using the given starting value (typically the rightidentity of the operator).
Filter
filter :: (a > Bool) > HashSet a > HashSet a #
O(n) Filter this set by retaining only elements satisfying a predicate.
Conversions
Lists
fromList :: (Eq a, Hashable a) => [a] > HashSet a #
O(n*min(W, n)) Construct a set from a list of elements.