rec-def-0.1: Recusively defined values
Safe HaskellSafe-Inferred



A very naive propagator library.

This propagator implementation keeps updating the values accoring to their definitions as other values change, until a fixed-point is reached.

It is a naive implementation and not very clever. Much more efficient propagator implementations are possible, and may be used by this library in the future.



data Prop a Source #

A cell in a propagator network


Instances details
Bottom x => Propagator (Prop x) x Source # 
Instance details

Defined in Data.Recursive.Propagator.Class


newProp :: IO (Prop x) Source #

newConstProp :: x -> IO (Prop x) Source #

readProp :: Prop x -> IO x Source #

newProp :: a -> IO (Prop a) Source #

Creates a cell, given an initial value

readProp :: Prop a -> IO a Source #

Reads the current value of the cell

watchProp :: Prop a -> IO () -> IO () Source #

Watch a cell: If the value changes, the given action is executed

setProp :: Eq a => Prop a -> IO a -> IO () Source #

Sets a new value calculated from the given action. The action is executed atomically.

If the value has changed, all watchers are notified afterwards (not atomically).

lift1 :: Eq b => (a -> b) -> Prop a -> Prop b -> IO () Source #

Whenever the first cell changes, update the second, using the given function

lift2 :: Eq c => (a -> b -> c) -> Prop a -> Prop b -> Prop c -> IO () Source #

Whenever any of the first two cells change, update the third, using the given function

liftList :: Eq b => ([a] -> b) -> [Prop a] -> Prop b -> IO () Source #

Whenever any of the cells in the list change, update the other, using the given function