module Data.Multimap.Set (
SetMultimap,
map,
delete,
member', notMember'
) where
import Prelude hiding (map)
import qualified Data.Map as Map
import Data.Maybe (maybe)
import Data.Set (Set)
import qualified Data.Set as Set
import Data.Multimap.Generic (Multimap(..), modifyMany)
type SetMultimap = Multimap Set
map :: (Ord k, Ord v1 , Ord v2) => (v1 -> v2) -> SetMultimap k v1 -> SetMultimap k v2
map f (Multimap m) = Multimap $ fmap (Set.map f) m
delete :: (Ord k, Ord v) => k -> v -> SetMultimap k v -> SetMultimap k v
delete k v = modifyMany (Set.delete v) k
member' :: (Ord k, Ord v) => k -> v -> SetMultimap k v -> Bool
member' k v (Multimap m) = maybe False (Set.member v) $ Map.lookup k m
notMember' :: (Ord k, Ord v) => k -> v -> SetMultimap k v -> Bool
notMember' k v mm = not $ member' k v mm