wxFruit: A Practical GUI Toolkit for
Functional Reactive Programming

Bart Robinson
Paul Hudak, Faculty Advisor
May 2004

PaddleBall implemented using wxFruit


The Haskell programming language has suffered in the past from the lack of a full-featured graphical user interface (GUI) toolkit. The situation has been improved recently by the introduction of wxHaskell, a library built upon the widely-used and feature-rich C++ GUI toolkit wxWidgets. However, the programming idioms used by wxHaskell are decidedly imperative, making wxHaskell a problematical choice for those who wish to keep with the functional and highly formal programming paradigms supported by Haskell.

The need for a "genuinely functional" user-interface toolkit has been addressed in the Fruit library, which brings the concepts of Functional Reactive Programming (FRP), a programming paradigm designed specifically for dynamic systems like user interfaces, to the world of GUIs. Fruit allows for a very elegant, declarative style of GUI programming in Haskell. However, the implementation of Fruit has been hindered by its reliance on a low-level graphics library to draw graphical elements, instead of interfacing to the host platform's GUI API. Thus Fruit, up till now, has been able to offer only a tiny fraction of the features available in most modern user interfaces.

In this paper I present my attempt to address the drawbacks of both wxHaskell and Fruit by replacing the implementation of Fruit with one that uses the GUI resources provided by wxHaskell. The resulting hybrid toolkit, called wxFruit, combines some of the power and versatility of wxHaskell with the elegance and simplicity of Fruit. I describe the obstacles faced in the design and implementation of wxFruit, discuss some of the issues that remain unresolved, and present a small application demonstrating the expressive power of the new toolkit.