SmallCounter


This program illustrates a more general way to combine application specific code with GUI elements from the Fudget library. It illustrates that state information can be encapsulated.

The program shows a button and a numeric display. Whenever the button is pressed, the number shown in the display is incremented.

The application specific code in this example sits between the button and the display. It internally maintains a counter which is incremented and output to the display whenever a click is received from the button.

Here is the source code:


module	Main(main) where -- A very simple counter
import Fudgets

main = fudlogue (shellF "Counter" counterF)

counterF = intDispF >==< absF countSP >==< buttonF "Increment"

countSP = mapAccumlSP inc 0
  where inc n _ = (n+1,n+1)

Things to note