VariableSet allow us to track changes to an unordered mutable set. The elements of the set are keyed by instancing HasKey with some Ord instance; this allows us to set up a special HasKey instance for this module without committing us to that Ord instance everywhere.
- class Ord key => HasKey x key | x -> key where
- toKey :: x -> key
- newtype Keyed x = Keyed x
- data VariableSetUpdate x
- = AddElement x
- | DelElement x
- | BeginGroup
- | EndGroup
- newtype VariableSet x = VariableSet (Broadcaster (VariableSetData x) (VariableSetUpdate x))
- newEmptyVariableSet :: HasKey x key => IO (VariableSet x)
- newVariableSet :: HasKey x key => [x] -> IO (VariableSet x)
- updateSet :: HasKey x key => VariableSet x -> VariableSetUpdate x -> IO ()
- setVariableSet :: HasKey x key => VariableSet x -> [x] -> IO ()
- type VariableSetSource x = Source [x] (VariableSetUpdate x)
- emptyVariableSetSource :: VariableSetSource x
- mapVariableSetSourceIO' :: (x -> IO (Maybe y)) -> VariableSetSource x -> VariableSetSource y
- concatVariableSetSource :: VariableSetSource x -> VariableSetSource x -> VariableSetSource x
- mapVariableSetSource :: (x -> y) -> VariableSetSource x -> VariableSetSource y
- singletonSetSource :: SimpleSource x -> VariableSetSource x
- listToSetSource :: Ord x => SimpleSource [x] -> VariableSetSource x
Documentation
Keyed x |
data VariableSetUpdate x Source
Encodes the updates to a variable set. BeginGroup does not actually alter the set itself, but indicate that a group of updates is about to begin, terminated by EndGroup. This prevents the client from trying to recalculate the state after every single update.
BeginGroup/EndGroup may be nested (though I don't have any application for that yet).
Functor VariableSetUpdate | |
HasKey x key => HasSource (VariableSet x) [x] (VariableSetUpdate x) | |
Ord key => HasSource (VariableMapSet key elt element) [element] (VariableSetUpdate element) |
newtype VariableSet x Source
VariableSet (Broadcaster (VariableSetData x) (VariableSetUpdate x)) |
Typeable1 VariableSet | |
HasKey x key => HasSource (VariableSet x) [x] (VariableSetUpdate x) |
newEmptyVariableSet :: HasKey x key => IO (VariableSet x)Source
Create a new empty variable set.
newVariableSet :: HasKey x key => [x] -> IO (VariableSet x)Source
Create a new variable set with given contents
updateSet :: HasKey x key => VariableSet x -> VariableSetUpdate x -> IO ()Source
Update a variable set in some way.
setVariableSet :: HasKey x key => VariableSet x -> [x] -> IO ()Source
Set the elements of the variable set.
type VariableSetSource x = Source [x] (VariableSetUpdate x)Source
mapVariableSetSourceIO' :: (x -> IO (Maybe y)) -> VariableSetSource x -> VariableSetSource ySource
mapVariableSetSource :: (x -> y) -> VariableSetSource x -> VariableSetSource ySource
listToSetSource :: Ord x => SimpleSource [x] -> VariableSetSource xSource
Creates a VariableSetSource whose elements are the same as those of the corresponding list.