Safe Haskell | None |
---|---|
Language | Haskell2010 |
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.
Synopsis
- 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).
Instances
Functor VariableSetUpdate Source # | |
Defined in Util.VariableSet fmap :: (a -> b) -> VariableSetUpdate a -> VariableSetUpdate b # (<$) :: a -> VariableSetUpdate b -> VariableSetUpdate a # | |
HasKey x key => HasSource (VariableSet x) [x] (VariableSetUpdate x) Source # | |
Defined in Util.VariableSet toSource :: VariableSet x -> Source [x] (VariableSetUpdate x) Source # |
newtype VariableSet x Source #
VariableSet (Broadcaster (VariableSetData x) (VariableSetUpdate x)) |
Instances
HasKey x key => HasSource (VariableSet x) [x] (VariableSetUpdate x) Source # | |
Defined in Util.VariableSet toSource :: VariableSet x -> Source [x] (VariableSetUpdate x) Source # |
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 y Source #
concatVariableSetSource :: VariableSetSource x -> VariableSetSource x -> VariableSetSource x Source #
mapVariableSetSource :: (x -> y) -> VariableSetSource x -> VariableSetSource y Source #
singletonSetSource :: SimpleSource x -> VariableSetSource x Source #
listToSetSource :: Ord x => SimpleSource [x] -> VariableSetSource x Source #
Creates a VariableSetSource whose elements are the same as those of the corresponding list.