Fudgets – Purely Functional Processes with applications to Graphical User Interfaces
Magnus Thomas Carlsson Hallgren
Department of Computing Science 1998
Do ctoral thesis for the degree of Do ctor of Philosophy
Fudgets
Purely Functional Pro cesses
with applications to
Graphical User Interfaces
Magnus Carlsson
Thomas Hallgren
EKNISKA T H S O R G E
S
M K
L
O
A
L
H A C G O G
TEBOR
Department of Computing Science
Chalmers University of Technology
G teb org University
S G teb org Sweden
G teb org
ISBN
ISSN X
http www cs chalmers se hallgren Thesis
Department of Computing Science
G teb org
Abstract
The main result of this thesis is a metho d for writing programs with graphical
user interfaces in purely functional languages The metho d is based on a new
abstraction called the fudget The metho d makes go o d use of key abstraction
p owers of functional languages such as higher order functions and parametric
p olymorphism
The Fudget concept is de ned in terms of the simpler concept of stream
processors which can b e seen as a simple but practically useful incarnation
of the pro cess concept Programs based on fudgets and stream pro cessors are
networks of communicating pro cesses that are built hierarchically using combi
nators Communication is typ e safe The basic combinators provide serial com
p ositions parallel comp ositions and lo ops A key di erence b etween previous
work on stream pro cessing functions and our approach is that we delib erately
abstract away from the streams We obtain a system that can b e implemented
deterministically entirely within a purely functional language but which also
makes it p ossible to take advantage of parallel evaluation and indeterminism
where such is available within the functional language The purely functional
approach makes pro cesses rst class values and makes it easy to express pro cess
cloning and pro cess migration
The practical viability of the approach is demonstrated by the Fudget li
brary which is an implementation of a graphical user interface to olkit in the
purely functional language Haskell together with a numb er of small an large
applications that have b een implemented on top of the library
In addition to GUI programming fudgets are suitable for other forms of
concurrent I O programming We demonstrate how client server based appli
cations can b e we written with typ e safe communication b etween client and
server We show a web browser as an example where GUI programming and
network communication come together
We view fudgets as one example of a more general combinator based ap
proach to promote the idea that a functional language together with combina
tor libraries is a go o d alternative to using less expressive languages propp ed
by application sp eci c to ols We describ e a set of combinators reminiscent of
parsing combinators for building syntax directed editors
Preface
This monograph acts as theses for b oth authors Most of the work b ehind has
b een carried out in close co op eration b etween the authors but some chapters
present work of a more individual nature
Thomas Hallgren Chapters and He has also develop ed the ap
plications in Part V some contributions are due to Magnus Carlsson in
Chapters and though
Magnus Carlsson Chapters and
Acknowledgements
We wish to thank Thomas Johnsson Lennart and Jessica Augustsson Johan
Nordlander Bengt Nordstr m Niklas R jemo David Sands Colin Runciman
and Simon Peyton Jones for pro ofreading and numerous suggestions for im
provements on drafts of the thesis A sp ecial thanks to Ola Freijd who has
made all illustrations and the cover page
Ideas and implementation work by a numb er of p eople have increased the
usefulness of the Fudget library Jan Sparud s space leak x in an early ver
sion suddenly made it p ossible to run fudget programs until someb o dy pulls the
plug Jan also implemented an initial version of the name layout mechanism
Lennart Augustsson s integration of the Xlib interface with HBC s runtime sys
tem made fudget programs easier to use and more e cient John Hughes in
vented the default parameter simulation which made fudget programming much
more pleasant
The department of Computing Science has not only provided a wealth of
academic stimulus but also technical and administrative supp ort that has shown
a exibility of unusual quality Esp ecially we want to thank Christer Carlsson
G rgen Olofsson Marie Larsson Per Lundgren and Hasse Hellstr m
Part of our work has b een supp orted by NUTEK