uni-util-2.3.0.3: Utilities for the uniform workbench
Safe HaskellNone
LanguageHaskell2010

Util.VariableSet

Description

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

Documentation

class Ord key => HasKey x key | x -> key where Source #

Methods

toKey :: x -> key Source #

newtype Keyed x Source #

Constructors

Keyed x 

Instances

Instances details
HasKey x key => Eq (Keyed x) Source #

HasKey specifies the ordering to use (without committing us to a particular Ord instance elsewhere).

Instance details

Defined in Util.VariableSet

Methods

(==) :: Keyed x -> Keyed x -> Bool #

(/=) :: Keyed x -> Keyed x -> Bool #

HasKey x key => Ord (Keyed x) Source # 
Instance details

Defined in Util.VariableSet

Methods

compare :: Keyed x -> Keyed x -> Ordering #

(<) :: Keyed x -> Keyed x -> Bool #

(<=) :: Keyed x -> Keyed x -> Bool #

(>) :: Keyed x -> Keyed x -> Bool #

(>=) :: Keyed x -> Keyed x -> Bool #

max :: Keyed x -> Keyed x -> Keyed x #

min :: Keyed x -> Keyed x -> 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

Instances details
Functor VariableSetUpdate Source # 
Instance details

Defined in Util.VariableSet

HasKey x key => HasSource (VariableSet x) [x] (VariableSetUpdate x) Source # 
Instance details

Defined in Util.VariableSet

newtype VariableSet x Source #

Constructors

VariableSet (Broadcaster (VariableSetData x) (VariableSetUpdate x)) 

Instances

Instances details
HasKey x key => HasSource (VariableSet x) [x] (VariableSetUpdate x) Source # 
Instance details

Defined in Util.VariableSet

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.

listToSetSource :: Ord x => SimpleSource [x] -> VariableSetSource x Source #

Creates a VariableSetSource whose elements are the same as those of the corresponding list.