From HaskellWiki
Revision as of 17:07, 27 April 2007 by Wolfgang Jeltsch (talk | contribs) (creation of initial version)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Grapefruit is a declarative library for creating graphical user interfaces. It is currently based on Gtk2Hs but implementations on top of other GUI libraries are planned for the future.

Grapefruit allows for implementing graphical user interfaces by describing them as systems of interconnected components. Components can be visible components like widgets and windows but also invisible components which provide certain control functionality. Component systems can be build from components by using methods from the Arrow and ArrowLoop classes.

Components communicate via signals and event streams. A signal denotes a value changing over time, and an event stream denotes a sequence of events occuring at discrete points in time. Several functions allow the construction of signals and event streams in a purely functional manner.

With Grapefruit, user interface descriptions always cover the complete lifetime of the respective interface. No explicit event handler registration and no explicit recalculation of values is necessary. This is in spirit with the declarative nature of Haskell because it stresses how the user interface operates instead of how this operation is achieved. However, under the hood, signals and event streams are implemented efficiently using the event dispatching and handling mechanism of the underlying GUI toolkit.

The roots of Grapefruit lie in systems like FranTk and wxFruit. Grapefruit tries to combine concepts of these systems with new ideas to become a system which maintains a reasonable balance between ease of use and efficiency.


As of May 2007, Grapefruit is in an early stage. The basic concepts are implemented but the implementation is still subject to notable change. Features planned for the next months cover support for dynamic user interfaces and animations as well as better handling of simultanous event occurences.

Source code

The source code of Grapefruit resides inside a Darcs repository under To get a copy, you can use the command darcs get


There is also documentation generated by Haddock. This documentation comes in two flavors. The API documentation covers only the public interface while the complete documentation covers also the internals.