Hets - the Heterogeneous Tool Set
Copyright(c) DFKI GmbH 2011
LicenseGPLv2 or higher, see LICENSE.txt
MaintainerChristian.Maeder@dfki.de
Stabilityprovisional
Portabilityportable
Safe HaskellSafe

Common.Lib.MapSet

Description

supply total mappings from keys to sets of values based on Data.Map. Undefined keys are mapped to the empty set. An abstract data type is needed to avoid differences due to empty set values versus undefined map keys.

Synopsis

Documentation

rmNullSets :: Ord a => Map a (Set b) -> Map a (Set b) Source #

remove empty elements from the map

setLookup :: Ord a => a -> Map a (Set b) -> Set b Source #

get elements for a key

setElems :: Ord b => Map a (Set b) -> Set b Source #

all elementes united

setMember :: (Ord a, Ord b) => a -> b -> Map a (Set b) -> Bool Source #

test for an element under a key

setInsert :: (Ord k, Ord a) => k -> a -> Map k (Set a) -> Map k (Set a) Source #

insert into a set of values

setAll :: (a -> Bool) -> Set a -> Bool Source #

test all elements of a set

setDifference :: Ord a => Set a -> Set a -> Maybe (Set a) Source #

difference function for differenceWith, returns Nothing for empty sets

setToMap :: Ord a => Set a -> Map a a Source #

convert a set into an identity map

restrict :: Ord k => Map k a -> Set k -> Map k a Source #

restrict a map by a keys set

imageList :: Ord k => Map k a -> Set k -> [a] Source #

the image of a map

imageSet :: (Ord k, Ord a) => Map k a -> Set k -> Set a Source #

the image of a map

data MapSet a b Source #

a map to non-empty sets

Instances

Instances details
(Eq a, Eq b) => Eq (MapSet a b) Source # 
Instance details

Defined in Common.Lib.MapSet

Methods

(==) :: MapSet a b -> MapSet a b -> Bool

(/=) :: MapSet a b -> MapSet a b -> Bool

(Data a, Data b, Ord b, Ord a) => Data (MapSet a b) Source # 
Instance details

Defined in Common.Lib.MapSet

Methods

gfoldl :: (forall d b0. Data d => c (d -> b0) -> d -> c b0) -> (forall g. g -> c g) -> MapSet a b -> c (MapSet a b)

gunfold :: (forall b0 r. Data b0 => c (b0 -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (MapSet a b)

toConstr :: MapSet a b -> Constr

dataTypeOf :: MapSet a b -> DataType

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (MapSet a b))

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (MapSet a b))

gmapT :: (forall b0. Data b0 => b0 -> b0) -> MapSet a b -> MapSet a b

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> MapSet a b -> r

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> MapSet a b -> r

gmapQ :: (forall d. Data d => d -> u) -> MapSet a b -> [u]

gmapQi :: Int -> (forall d. Data d => d -> u) -> MapSet a b -> u

gmapM :: Monad m => (forall d. Data d => d -> m d) -> MapSet a b -> m (MapSet a b)

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> MapSet a b -> m (MapSet a b)

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> MapSet a b -> m (MapSet a b)

(Ord a, Ord b) => Ord (MapSet a b) Source # 
Instance details

Defined in Common.Lib.MapSet

Methods

compare :: MapSet a b -> MapSet a b -> Ordering

(<) :: MapSet a b -> MapSet a b -> Bool

(<=) :: MapSet a b -> MapSet a b -> Bool

(>) :: MapSet a b -> MapSet a b -> Bool

(>=) :: MapSet a b -> MapSet a b -> Bool

max :: MapSet a b -> MapSet a b -> MapSet a b

min :: MapSet a b -> MapSet a b -> MapSet a b

(Ord a, Read a, Ord b, Read b) => Read (MapSet a b) Source # 
Instance details

Defined in Common.Lib.MapSet

Methods

readsPrec :: Int -> ReadS (MapSet a b)

readList :: ReadS [MapSet a b]

readPrec :: ReadPrec (MapSet a b)

readListPrec :: ReadPrec [MapSet a b]

(Show a, Show b) => Show (MapSet a b) Source # 
Instance details

Defined in Common.Lib.MapSet

Methods

showsPrec :: Int -> MapSet a b -> ShowS

show :: MapSet a b -> String

showList :: [MapSet a b] -> ShowS

Generic (MapSet a b) Source # 
Instance details

Defined in Common.Lib.MapSet

Associated Types

type Rep (MapSet a b) :: Type -> Type

Methods

from :: MapSet a b -> Rep (MapSet a b) x

to :: Rep (MapSet a b) x -> MapSet a b

(Ord a, FromJSON a, Ord b, FromJSON b, FromJSONKey a) => FromJSON (MapSet a b) 
Instance details

Defined in Common.Json.ConvInstances

Methods

parseJSON :: Value -> Parser (MapSet a b)

parseJSONList :: Value -> Parser [MapSet a b]

(Ord a, ToJSON a, Ord b, ToJSON b, ToJSONKey a) => ToJSON (MapSet a b) 
Instance details

Defined in Common.Json.ConvInstances

Methods

toJSON :: MapSet a b -> Value

toEncoding :: MapSet a b -> Encoding

toJSONList :: [MapSet a b] -> Value

toEncodingList :: [MapSet a b] -> Encoding

(Ord a, ShATermConvertible a, Ord b, ShATermConvertible b) => ShATermConvertible (MapSet a b) 
Instance details

Defined in Common.ATerm.ConvInstances

Methods

toShATermAux :: ATermTable -> MapSet a b -> IO (ATermTable, Int)

toShATermList' :: ATermTable -> [MapSet a b] -> IO (ATermTable, Int)

fromShATermAux :: Int -> ATermTable -> (ATermTable, MapSet a b)

fromShATermList' :: Int -> ATermTable -> (ATermTable, [MapSet a b])

type Rep (MapSet a b) Source # 
Instance details

Defined in Common.Lib.MapSet

type Rep (MapSet a b) = D1 ('MetaData "MapSet" "Common.Lib.MapSet" "main" 'True) (C1 ('MetaCons "MapSet" 'PrefixI 'True) (S1 ('MetaSel ('Just "toMap") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map a (Set b)))))

toMap :: MapSet a b -> Map a (Set b) Source #

fromDistinctMap :: Map a (Set b) -> MapSet a b Source #

unsafe variant of fromMap (without removal of empty sets)

fromMap :: Ord a => Map a (Set b) -> MapSet a b Source #

remove empty values from the map before applying wrapping constructor

empty :: MapSet a b Source #

the empty relation

null :: MapSet a b -> Bool Source #

test for the empty mapping

fromList :: (Ord a, Ord b) => [(a, [b])] -> MapSet a b Source #

convert from a list

toList :: MapSet a b -> [(a, [b])] Source #

convert to a list

toPairList :: MapSet a b -> [(a, b)] Source #

keysSet :: MapSet a b -> Set a Source #

keys for non-empty elements

elems :: Ord b => MapSet a b -> Set b Source #

all elementes united

insert :: (Ord a, Ord b) => a -> b -> MapSet a b -> MapSet a b Source #

insert an element under the given key

update :: (Ord a, Ord b) => (Set b -> Set b) -> a -> MapSet a b -> MapSet a b Source #

update an element set under the given key

lookup :: Ord a => a -> MapSet a b -> Set b Source #

get elements for a key

member :: (Ord a, Ord b) => a -> b -> MapSet a b -> Bool Source #

test for an element under a key

delete :: (Ord a, Ord b) => a -> b -> MapSet a b -> MapSet a b Source #

delete an element under the given key

union :: (Ord a, Ord b) => MapSet a b -> MapSet a b -> MapSet a b Source #

union of two maps

difference :: (Ord a, Ord b) => MapSet a b -> MapSet a b -> MapSet a b Source #

difference of two maps

intersection :: (Ord a, Ord b) => MapSet a b -> MapSet a b -> MapSet a b Source #

intersection of two maps

map :: (Ord b, Ord c) => (b -> c) -> MapSet a b -> MapSet a c Source #

map a function to all elements

mapMonotonic :: (b -> c) -> MapSet a b -> MapSet a c Source #

unsafe map a function to all elements

mapSet :: Ord a => (Set b -> Set c) -> MapSet a b -> MapSet a c Source #

apply a function to all element sets

foldWithKey :: (a -> b -> c -> c) -> c -> MapSet a b -> c Source #

fold over all elements

filter :: (Ord a, Ord b) => (b -> Bool) -> MapSet a b -> MapSet a b Source #

filter elements

partition :: (Ord a, Ord b) => (b -> Bool) -> MapSet a b -> (MapSet a b, MapSet a b) Source #

partition elements

filterWithKey :: Ord a => (a -> Set b -> Bool) -> MapSet a b -> MapSet a b Source #

filter complete entries

all :: Ord b => (b -> Bool) -> MapSet a b -> Bool Source #

test all elements

isSubmapOf :: (Ord a, Ord b) => MapSet a b -> MapSet a b -> Bool Source #

submap test

preImage :: (Ord a, Ord b) => Map a b -> MapSet b a Source #

pre-image of a map

transpose :: (Ord a, Ord b) => MapSet a b -> MapSet b a Source #

transpose a map set