Safe Haskell | None |
---|---|
Language | Haskell2010 |
Small experimental library for interactive functional programs.
- data X a
- data E a
- never :: E a
- snapshot :: E a -> X b -> E (a, b)
- snapshot_ :: E a -> X b -> E b
- accumulate :: E a -> s -> (a -> s -> s) -> X s
- edge :: X a -> (a -> a -> Maybe b) -> E b
- justE :: E (Maybe a) -> E a
- maybeE :: (a -> Maybe b) -> E a -> E b
- filterE :: (a -> Bool) -> E a -> E a
- data Setup a
- runProgram :: Setup (IO (), E ()) -> IO ()
- newX :: a -> Setup (X a, a -> IO ())
- newE :: Setup (E a, a -> IO ())
- input :: IO () -> Setup ()
- output :: E a -> (a -> IO ()) -> Setup ()
- debugX :: (Eq a, Show a) => X a -> X a
- debugE :: Show a => E a -> E a
Documentation
snapshot :: E a -> X b -> E (a, b) Source
An event which gets the value of a signal when another event occurs.
accumulate :: E a -> s -> (a -> s -> s) -> X s Source
Sum over events using an initial state and a state transition function.
edge :: X a -> (a -> a -> Maybe b) -> E b Source
An event that occurs when an edge is detected in a signal. The edge test is applied to values before and after a discrete transition in the signal. The test should return Nothing when the two values are the same.
A monad for hooking up inputs and outputs to a program.
runProgram :: Setup (IO (), E ()) -> IO () Source
Run the setup action to create input and output threads. The returned IO action will be executed when setup is complete. runProgram blocks until the returned event occurs, at which time it kills all the threads and returns.
newX :: a -> Setup (X a, a -> IO ()) Source
Creates a new signal and an IO action to update it. The argument is the initial value of the signal.
output :: E a -> (a -> IO ()) -> Setup () Source
Spawn a thread to execute an action for each event occurrence.