Safe Haskell | None |
---|
Var
is the reference type used for incremental computing. It has a cached value
and a list of dependent children to update when it changes.
The update propogation happens automatically when using either modifyVar
or
writeVar
. Same with the STM
variants.
Additionally updates can be triggered manually with update
Var
is low level and is used by Tweakable
and to create incremental expressions.
- data Var a = Var {}
- data AnyVar = forall a . AnyVar (Var a)
- type Update = STM ()
- type Children = Map AnyVar Update
- class Cacheable a where
- output :: Lens (Var a) (Var b) (TVar a) (TVar b)
- identifier :: Lens (Var a) (Var a) Unique Unique
- update :: Cacheable a => a -> STM ()
- addChild :: Cacheable a => a -> AnyVar -> Update -> IO ()
- addChildSTM :: Cacheable a => a -> AnyVar -> Update -> STM ()
- newVar :: a -> IO (Var a)
- readVar :: Var a -> IO a
- modifyVar :: Var a -> (a -> a) -> IO ()
- writeVar :: Var a -> a -> IO ()
- newVarSTM :: a -> STM (Var a)
- readVarSTM :: Var a -> STM a
- modifyVarSTM :: Var a -> (a -> a) -> STM ()
- writeVarSTM :: Var a -> a -> STM ()
Reference for Incremental Computing
This a reference for incremental computation. Not only does it include a value, But is also has a list of actions to execute when it is updated.
Existential Var Wrapper
Helpers
Lenses
identifier :: Lens (Var a) (Var a) Unique UniqueSource
Dependency Manipulation
update :: Cacheable a => a -> STM ()Source
Recursively call update on the children of a Var
like thing
:: Cacheable a | |
=> a | The input that contains the reference to add children to |
-> AnyVar | The child |
-> Update | The update action to call when the input is updated. |
-> IO () |
Add a dependent child to the Var
s children, or any type that has Var
like
Children
See addChildSTM
for the STM
version
Var IO CRU
modifyVar :: Var a -> (a -> a) -> IO ()Source
Modify a Var
and update the children.
See modifyVarSTM
for the STM
version
writeVar :: Var a -> a -> IO ()Source
Write a new value into a Var
and update all of the children.
See writeVarSTM
for the STM
version
Var STM CRU
modifyVarSTM :: Var a -> (a -> a) -> STM ()Source