Safe Haskell | Safe-Inferred |
---|---|

Language | Haskell2010 |

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.

## Synopsis

- data Prop a
- newProp :: a -> IO (Prop a)
- readProp :: Prop a -> IO a
- watchProp :: Prop a -> IO () -> IO ()
- setProp :: Eq a => Prop a -> IO a -> IO ()
- lift1 :: Eq b => (a -> b) -> Prop a -> Prop b -> IO ()
- lift2 :: Eq c => (a -> b -> c) -> Prop a -> Prop b -> Prop c -> IO ()
- liftList :: Eq b => ([a] -> b) -> [Prop a] -> Prop b -> IO ()

# Documentation

A cell in a propagator network

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