uni-util-2.2.1.1: Utilities for the uniform workbench

Util.VariableMap

Description

VariableMap is analagous to VariableSet and provides a mutable map ordered by key whose changes can be tracked.

Synopsis

Documentation

data VariableMapData key elt Source

Describes a map update. For DelUpdate, the second parameter (the one of type elt) is irrelevant and may be undefined.

Instances

Ord key => HasSource (VariableMap key elt) (VariableMapData key elt) (VariableMapUpdate key elt)

Unlike VariableSet, the contents of a variable map are not returned in concrete form but as the abstract data type VariableMapData. We provide functions for querying this.

newtype VariableMapUpdate key elt Source

We recycle the VariableSetUpdate type for this.

Constructors

VariableMapUpdate (VariableSetUpdate (key, elt)) 

Instances

Ord key => HasSource (VariableMap key elt) (VariableMapData key elt) (VariableMapUpdate key elt)

Unlike VariableSet, the contents of a variable map are not returned in concrete form but as the abstract data type VariableMapData. We provide functions for querying this.

data VariableMap key elt Source

Instances

Typeable2 VariableMap 
Ord key => HasSource (VariableMap key elt) (VariableMapData key elt) (VariableMapUpdate key elt)

Unlike VariableSet, the contents of a variable map are not returned in concrete form but as the abstract data type VariableMapData. We provide functions for querying this.

newEmptyVariableMap :: Ord key => IO (VariableMap key elt)Source

Create a new empty variable map.

newVariableMap :: Ord key => [(key, elt)] -> IO (VariableMap key elt)Source

Create a new variable map with given contents

newVariableMapFromFM :: Ord key => Map key elt -> IO (VariableMap key elt)Source

updateMap :: Ord key => VariableMap key elt -> VariableMapUpdate key elt -> IO BoolSource

Update a variable map in some way. Returns True if the update was sucessful (so for insertions, the object is not already there; for deletions the object is not there).

lookupMap :: Ord key => VariableMapData key elt -> key -> Maybe eltSource

lookupWithDefaultMap :: Ord key => VariableMapData key elt -> elt -> key -> eltSource

mapToList :: Ord key => VariableMapData key elt -> [(key, elt)]Source

mapToFM :: Ord key => VariableMapData key elt -> Map key eltSource

mapToVariableSetSource :: Ord key => (key -> elt -> element) -> VariableMap key elt -> VariableSetSource elementSource

Given a variable map and conversion function, produce a VariableSetSource

addToVariableMap :: Ord key => VariableMap key elt -> key -> elt -> IO BoolSource

delFromVariableMap :: Ord key => VariableMap key elt -> key -> IO BoolSource

variableMapToList :: Ord key => VariableMap key elt -> IO [(key, elt)]Source

lookupVariableMap :: Ord key => VariableMap key elt -> key -> IO (Maybe elt)Source

getVariableMapByKey :: Ord key => VariableMap key elt -> key -> SimpleSource (Maybe elt)Source