Contents

1 Abstract

TV is a library for composing tangible values ("TVs"), i.e., values that carry along external interfaces. In particular, TVs can be composed to create new TVs, and they can be directly executed with a friendly GUI, a process that reads and writes character streams, or many other kinds interfaces. Values and interfaces are combined for direct use, and separable for composition. This combination makes for software that is ready to use and ready to reuse.

TV can be thought of as a simple functional formulation of the Model-View-Controller pattern. (My thanks to an anonymous ICFP referee for pointing out this connection.) The value part of a TV is the model, and the "interface" part, or "output" as it is called below, is the viewer. Outputs are built up compositionally from other outputs and from inputs (the controllers), as described below.

As of version 0.2, I have moved the GUI functionality out of TV and into a small new package GuiTV. I moved it out to eliminate the dependency of core TV on Phooey and hence on wxHaskell, as the latter can be difficult to install. The GUI examples below require GuiTV.

2 First Example

function combines an interface and a value. In this example, the interface is the default for string functions, wrapped with the title "reverse".
TV "interfaces" are more than just GUIs. Here are two different renderings of

3 Outputs

prefix is explained below. At the heart of TV is a small algebra for constructing these outputs. Weve already seen one output function,

oTitle

. Another one is

showOut

, which is an output for all

Show

types. For instance,

total ::Show a => COutput a
total = oTitle "total" showOut

4 Inputs and function-valued outputs

Just as an output is a way to deliver (or consume) a value, an "input" is a way to obtain (or produce) a value. For example, here are two inputs, each specifying an initial value and a value range, and each given a title.

6 The general story

TVs, outputs, and inputs are not restricted to GUIs and IO. In general, they are parameterized by the mechanics of "transmitting values", i.e., delivering ("sinking") output and gathering ("sourcing") input.