broccoli-0.1.0.0: Small library for interactive functional programs.

Safe HaskellNone
LanguageHaskell2010

Control.Broccoli

Description

Small experimental library for interactive functional programs.

Synopsis

Documentation

data X a Source

A value of type a that varies.

Instances

data E a Source

An event that carries values of type a when it occurs.

Instances

Functor E 
Monoid (E a) 

newtype Output Source

A special IO action which will react to events. See out.

Constructors

Output (IO ()) 

runProgram Source

Arguments

:: IO ()

action to execute after initialization

-> E ()

event that will shutdown the system

-> [Output]

set of output event handlers to run

-> IO () 

Run a set of Outputs. This spawns several threads then waits for an event. The output threads will then be killed to stop further processing. However other threads which no longer have any effect will probably remain, taking up resources. After threads have been spawned but before waiting, the given "boot" action will be executed.

edge :: X a -> (a -> a -> Maybe b) -> E b Source

Events will occur when an "edge" is detected in a signal. The detection algorithm checks the two values before and after a discrete change in the signal.

accumulate :: E a -> s -> (a -> s -> s) -> X s Source

Create a signal out of an input event and a state machine.

snapshot :: E a -> X b -> E (a, b) Source

An event which gets the value of a signal when another event occurs.

snapshot_ :: E a -> X b -> E b Source

Like snapshot but ignores the original event's payload.

out :: E a -> (a -> IO ()) -> Output Source

A handler for events.

filterE :: (a -> Bool) -> E a -> E a Source

Filter out events using a Bool function.

justE :: E (Maybe a) -> E a Source

Filter out events with the value of Nothing.

maybeE :: (a -> Maybe b) -> E a -> E b Source

Filter out events using a Maybe function.

never :: E a Source

An event that never happens.

debugX :: (Eq a, Show a) => X a -> Output Source

Prints the values of a signal as they change.

debugE :: Show a => E a -> Output Source

Prints the values of events as they occur.

newX :: a -> IO (a -> IO (), X a) Source

Create a new signal with an initial value. Get back an IO action to change the value of the signal. This is the only way the signal will change.

newE :: IO (a -> IO (), E a) Source

Create a new event and the associated IO action to trigger the event.