-- | Haskell implementations of hydra/lib/sets primitives

module Hydra.Lib.Sets where

import qualified Data.Set as S


contains :: Ord x => x -> S.Set x -> Bool
contains :: forall x. Ord x => x -> Set x -> Bool
contains = x -> Set x -> Bool
forall x. Ord x => x -> Set x -> Bool
S.member

difference :: Ord x => S.Set x -> S.Set x -> S.Set x
difference :: forall x. Ord x => Set x -> Set x -> Set x
difference = Set x -> Set x -> Set x
forall x. Ord x => Set x -> Set x -> Set x
S.difference

empty :: S.Set x
empty :: forall x. Set x
empty = Set x
forall x. Set x
S.empty

fromList :: Ord x => [x] -> S.Set x
fromList :: forall x. Ord x => [x] -> Set x
fromList = [x] -> Set x
forall x. Ord x => [x] -> Set x
S.fromList

insert :: Ord x => x -> S.Set x -> S.Set x
insert :: forall x. Ord x => x -> Set x -> Set x
insert = x -> Set x -> Set x
forall x. Ord x => x -> Set x -> Set x
S.insert

intersection :: Ord x => S.Set x -> S.Set x -> S.Set x
intersection :: forall x. Ord x => Set x -> Set x -> Set x
intersection = Set x -> Set x -> Set x
forall x. Ord x => Set x -> Set x -> Set x
S.intersection

isEmpty :: S.Set x -> Bool
isEmpty :: forall x. Set x -> Bool
isEmpty = Set x -> Bool
forall x. Set x -> Bool
S.null

-- Note: the presence of a 'map' function does not imply that sets are a functor in Hydra
map :: Ord y => (x -> y) -> S.Set x -> S.Set y
map :: forall y x. Ord y => (x -> y) -> Set x -> Set y
map x -> y
f = [y] -> Set y
forall x. Ord x => [x] -> Set x
S.fromList ([y] -> Set y) -> (Set x -> [y]) -> Set x -> Set y
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (x -> y) -> [x] -> [y]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap x -> y
f ([x] -> [y]) -> (Set x -> [x]) -> Set x -> [y]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Set x -> [x]
forall a. Set a -> [a]
S.toList

remove :: Ord x => x -> S.Set x -> S.Set x 
remove :: forall x. Ord x => x -> Set x -> Set x
remove = x -> Set x -> Set x
forall x. Ord x => x -> Set x -> Set x
S.delete

singleton :: x -> S.Set x
singleton :: forall x. x -> Set x
singleton = x -> Set x
forall x. x -> Set x
S.singleton

size :: S.Set x -> Int
size :: forall x. Set x -> Int
size = Set x -> Int
forall x. Set x -> Int
S.size

toList :: Ord x => S.Set x -> [x]
toList :: forall x. Ord x => Set x -> [x]
toList = Set x -> [x]
forall a. Set a -> [a]
S.toList

union :: Ord x => S.Set x -> S.Set x -> S.Set x
union :: forall x. Ord x => Set x -> Set x -> Set x
union = Set x -> Set x -> Set x
forall x. Ord x => Set x -> Set x -> Set x
S.union