UISF- Library for Arrowized Graphical User Interfaces.

Safe HaskellNone




runUI' :: UISF () () -> IO () Source

Run the UISF with the default settings.

runUI :: UIParams -> UISF () () -> IO () Source

Run the UISF with the given parameters.

data UIParams Source

The UIParams data type provides an interface for modifying some of the settings for runUI without forcing runUI to take a zillion arguments. Typical usage will be to modify the below defaultUIParams using record syntax.


defaultUIParams :: UIParams Source

This is the default UIParams value and what is used in runUI'.

uiInitialize :: UIParams -> IO () Source

An initialization action.

uiClose :: UIParams -> IO () Source

A termination action.

uiTitle :: UIParams -> String Source

The UI window's title.

uiSize :: UIParams -> Dimension Source

The size of the UI window.

uiInitFlow :: UIParams -> Flow Source

The initial Flow setting.

uiTickDelay :: UIParams -> DeltaT Source

How long the UI will sleep between clock ticks if no events are detected. This should be probably be set to O(milliseconds), but it can be set to 0 for better performance (but also higher CPU usage)

uiCloseOnEsc :: UIParams -> Bool Source

Should the UI window close when the user presses the escape key?

uiBackground :: UIParams -> RGB Source

The default color of the UI window background.

type Dimension = (Int, Int) Source

A dimension specifies size.

label :: UITexty s => s -> UISF a a Source

Labels are always left aligned and vertically centered.

displayStr :: UISF String () Source

DisplayStr is an output widget showing the instantaneous value of a signal of strings.

display :: Show a => UISF a () Source

display is a widget that takes any show-able value and displays it.

withDisplay :: Show b => UISF a b -> UISF a b Source

withDisplay is a widget modifier that modifies the given widget so that it also displays its output value.

data WrapSetting Source

The Wrap Setting is used to determine how to split up a long piece of text.



displayField :: UITexty s => WrapSetting -> UISF s () Source

DisplayField is an output widget showing the instantaneous value of a signal of Strings. It will show the String over how ever much space it has available to it. The static argument will decide what to cut off in the case where it does not have space to show the entire String: if given True, it will prefer the older characters (cutting off later text), and if given False, it will prefer the newer characters (cutting off older ones.

textbox :: UITexty s => s -> UISF (SEvent s) String Source

The textbox widget creates a one line field where users can enter text. It supports mouse clicks and typing as well as the left, right, end, home, delete, and backspace special keys.

The value displayed can be generated by mouse and keyboard events, but it can also be set programmatically by providing the widget's input stream with an event containing the value to display. By using rec and delay, one can update the contents based on e.g. other widgets.

The static argument provides the textbox with initial text.

textField :: UITexty s => WrapSetting -> s -> UISF (SEvent s) UIText Source

TextFields are like textboxes but can support multiple lines. By default, they are stretchy in the vertical dimension.

textboxE :: UITexty s => s -> UISF (SEvent s) String Source

Deprecated: As of UISF-, use textbox instead

title :: UITexty s => s -> UISF a b -> UISF a b Source

Title frames a UI by borders, and displays a static title text.

spacer :: UISF a a Source

spacer is an empty widget that will take up empty space without requesting any space. This can be useful for lining up other widgets, for instance if one wants the borders from titles to align even when the titles are bordering widgets of slightly different sizes.

button :: UITexty s => s -> UISF () Bool Source

A button is a focusable input widget with a state of being on or off. It can be activated with either a button press, the enter key, or the space key. Buttons also show a static label.

The regular button is down as long as the mouse button or key press is down and then returns to up.

stickyButton :: UITexty s => s -> UISF () Bool Source

The sticky button, on the other hand, once pressed, remains depressed until is is clicked again to be released. Thus, it looks like a button, but it behaves more like a checkbox.

checkbox :: UITexty s => s -> Bool -> UISF () Bool Source

Checkbox allows selection or deselection of an item. It has a static label as well as an initial state.

checkGroup :: [(String, a)] -> UISF () [a] Source

The checkGroup widget creates a group of checkboxes that all send their outputs to the same output stream. It takes a static list of labels for the check boxes and assumes they all start unchecked.

The output stream is a list of each a value that was paired with a String value for which the check box is checked.

radio :: UITexty s => [s] -> Int -> UISF () Int Source

Radio button presents a list of choices and only one of them can be selected at a time. It takes a static list of choices (as Strings) and the index of the initially selected one, and the widget itself returns the continuous stream representing the index of the selected choice.

hSlider :: RealFrac a => (a, a) -> a -> UISF () a Source

Horizontal Continuous Slider

vSlider :: RealFrac a => (a, a) -> a -> UISF () a Source

Vertical Continuous Slider

hiSlider :: Integral a => a -> (a, a) -> a -> UISF () a Source

Horizontal Discrete Slider

viSlider :: Integral a => a -> (a, a) -> a -> UISF () a Source

Vertical Discrete Slider

realtimeGraph :: RealFrac a => Layout -> DeltaT -> Color -> UISF [(a, Time)] () Source

The realtimeGraph widget creates a graph of the data with trailing values. It takes a dimension parameter, the length of the history of the graph measured in time, and a color for the graphed line. The signal function then takes an input stream of (value,time) event pairs, but since there can be zero or more points at once, we use [] rather than SEvent for the type. The values in the (value,time) event pairs should be between -1 and 1.

data Color Source

We provide a data type for colors to allow users to easily and clearly specify common colors. Primary and secondary RGB colors are represented along with a few beige colors for use in many GUI elements.



This is the default background color for the UI window.


histogram :: RealFrac a => Layout -> UISF (SEvent [a]) () Source

The histogram widget creates a histogram of the input map. It assumes that the elements are to be displayed linearly and evenly spaced. Also, the values to be plotted must be between 0 and 1 (inclusive).

histogramWithScale :: RealFrac a => Layout -> UISF (SEvent [(a, String)]) () Source

The histogramWithScale widget creates a histogram and an x coordinate scale.

scrollable :: Layout -> Dimension -> UISF a b -> UISF a b Source

The scrollable function puts sub-widgets into a virtual canvas that can be scrolled using sliders that appear when necessary. The first argument is the actual layout of the scrollable area, and the second argument is the size of the virtual canvas.

listbox :: (Eq a, Show a) => [a] -> Int -> UISF (SEvent [a], SEvent Int) Int Source

The listbox widget creates a box with selectable entries. It takes two static values indicating the initial list of data to display and the initial index selected (use -1 for no selection). It takes two event streams that can be used to independently set the list and index. The output stream is the currently selected index.

Note that the index can be greater than the length of the list (simply indicating no choice selected).

listbox' :: (Eq a, Show a) => UISF ([a], Int) Int Source

This variant of listbox does not keep its list or index stored internally and thus accepts a stream of those values. As such, it requires no static initializing parameters. This can be useful when the list or index are being updated frequently.

canvas :: Dimension -> UISF (SEvent Graphic) () Source

Canvas displays any graphics. The input is a signal of graphics events because we only want to redraw the screen when the input is there.

canvas' :: Layout -> (a -> Dimension -> Graphic) -> UISF (SEvent a) () Source

canvas' uses a layout and a graphic generator. This allows it to behave similarly to canvas, but it can adjust in cases with stretchy layouts.

topDown :: UISF a b -> UISF a b Source

bottomUp :: UISF a b -> UISF a b Source

leftRight :: UISF a b -> UISF a b Source

rightLeft :: UISF a b -> UISF a b Source

pad :: (Int, Int, Int, Int) -> UISF a b -> UISF a b Source

Add space padding around a widget.

setSize :: Dimension -> UISF a b -> UISF a b Source

A convenience function for setLayout, setSize sets the layout to a fixed size (in pixels).

setLayout :: Layout -> UISF a b -> UISF a b Source

Set a new layout for this widget.

makeLayout Source


:: LayoutType

Horizontal Layout information

-> LayoutType

Vertical Layout information

-> Layout 

Layouts for individual widgets typically come in a few standard flavors, so we have this convenience function for their creation. This function takes layout information for first the horizontal dimension and then the vertical.

data LayoutType Source

A dimension can either be:



Stretchy with a minimum size in pixels


minSize :: Int

Fixed with a size measured in pixels


fixedSize :: Int

data Layout Source

More complicated layouts can be manually constructed with direct access to the Layout data type.

  1. wStretch and hStretch specify how much stretching space (in comparative units) in the width and height should be allocated for this widget.
  2. wFixed and hFixed specify how much non-stretching space (in pixels) of width and height should be allocated for this widget.
  3. wMin and hMin specify minimum values (in pixels) of width and height for the widget's stretchy dimensions.
  4. lFill specifies how much expanding space (in comparative units) this widget should fill out in excess space that would otherwise be unused.


getTime :: UISF () Time Source

Deprecated: As of UISF-, use accumTime instead, which is a little different but should work fine

getDeltaTime :: UISF b DeltaT Source

Get the time signal from a UISF.

class Arrow a => ArrowIO a where Source

Instances of the ArrowIO class have an arrowized ability to perform IO actions.


liftAIO :: (b -> IO c) -> a b c Source

The liftAIO function lifts an IO action into an arrow.

initialAIO :: IO d -> (d -> a b c) -> a b c Source

The initialAIO function performs an IO action once when the arrow is first initialized and then uses the result of that action to generate the arrow itself.

terminalAIO :: IO () -> a b b Source

The terminalAIO function stores an IO action to be performed once when the arrow terminates. This will typically be some sort of clean up behavior.


asyncVT Source


:: (ArrowIO a, ArrowCircuit a, ArrowReader DeltaT a, NFData c) 
=> Double


-> DeltaT

Amount of time to buffer

-> PureAuto b c

The automaton to run virtually

-> a b [(c, Time)] 

A variant of asyncV that uses a built-in time step of the arrow to accumulate and use the current time.

asyncE Source


:: (ArrowIO a, ArrowLoop a, ArrowCircuit a, ArrowChoice a, NFData c) 
=> PureAuto b c

The automaton to convert to asynchronize

-> a (SEvent b) (SEvent c) 

The asyncE (E for "Event") function takes a signal function (an Automaton) and converts it into an asynchronous event-based signal function usable in a ArrowIO signal function context. The output arrow takes events of type a, feeds them to the asynchronously running input signal function, and returns events with the output b whenever they are ready. The input signal function is expected to run slowly compared to the output one, but it is capable of running just as fast.

asyncC Source


:: (ArrowIO a, ArrowLoop a, ArrowCircuit a, ArrowChoice a, NFData c) 
=> PureAuto b c

The automaton to convert to realtime

-> a b [c] 

The asyncC (C for "Continuous time") function allows a continuous signal function to run as fast as it can asynchronously. There are no guarantees that all input data make it to the asynchronous signal function; if this is required, asyncE should be used instead. Rather, the embedded signal function runs as fast as it can on whatever value it has most recently seen. Its results are bundled together in a list to be returned to the main signal function.