Set.purs 465 Bytes
Newer Older
1 2
module Gargantext.Utils.Set where

3 4
import Data.Array as A
import Data.Hashable (class Hashable, hash)
5 6
import Data.Ord (class Ord)
import Data.Set as Set
7
import Prelude (($))
8 9


10 11 12
-- instance (Hashable a, Ord a) => Hashable (Set.Set a) where
--   hash s = hash $ A.sort $ A.fromFoldable s

13 14 15
-- | If `a` is in Set, remove it, otherwise add it
toggle :: forall a. Ord a => Set.Set a -> a -> Set.Set a
toggle s x = if Set.member x s then Set.delete x s else Set.insert x s