
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 Gteb org University S Gteb org Sweden Gteb org ISBN ISSN X httpwwwcschalmerssehallgrenThesis Department of Computing Science Gteb 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 dened 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 dierence 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 IO programming We demonstrate how clientserver 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 combinatorbased 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 applicationsp ecic to ols We describ e a set of combinators reminiscent of parsing combinators for building syntaxdirected 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 Nordstrm Niklas Rjemo 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 Sparuds spaceleak 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 Augustssons integration of the Xlib interface with HBCs runtime sys tem made fudget programs easier to use and more ecient 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 Grgen Olofsson Marie Larsson Per Lundgren and Hasse Hellstrm Part of our work has b een supp orted by NUTEK Historical reections Once up on a time on a gray autumn day in three functional programmers were chatting during a coee break They were quite happy that the LML compiler AJ allowed them to write real programs in a pure functional language One of these three had implemented a version of the game Tetris in LML Another had implemented Worms an interactive multiuser realtime game Hal They had no eciency problems with these kinds of programs even though the computers of that time were times slower than the ones we use to day But at that time the three functional programmers were b eginning to use graphical workstations instead of simple text terminals They were unhappy ab out the fact that they did not have a way to write programs with graphical user interfaces in their functional language The two younger of the three functional programmers decided to start work ing on a solution to this problem The older of the three was a bit skeptical and said that it would probably not b e p ossible to obtain a solution that was ecient enough to write real programs with The two younger implemented an interface that allowed LML programs to talk to the X Windows system They also designed an abstraction to b e used as the basic building blo ck when constructing graphical user interfaces This abstraction was later named the Fudget The rst X Windows interface was implemented as a separate program that the LML program could talk to via ordinary text IO The oldest programmer later integrated the interface with the runtime system of the LML compiler making the interface much more ecient Approximately one year later the two younger functional programmers felt they had a reasonably ecient system and a fairly nice abstraction They wrote a pap er ab out it and it was accepted at a functional programming conference CHb One of the younger functional programmers wrote some more ab out it and turned it into a licentiate thesis CHa The work continued A numb er of improvements to make it easer to write programs were made and the library was converted into Haskell Improvements to the layout system allowed layout and plumbing to b e sp ecied separately A lot of distracting extra function arguments could b e removed after a parameter passing mechanism with default values was intro duced The resulting version of the Fudget library was presented at the Spring Scho ol on Advanced Functional Programming in Bstad in HC Contents Preface Acknowledgements : : : : : : : : : : : : : : : : : : : : : : : : : : : : : Historical reections : : : : : : : : : : : : : : : : : : : : : : : : : : : : I Intro duction Programming by combination : : : : : : : : : : : : : : : : : : : : : : Combinator libraries replace to ols : : : : : : : : : : : : : : : : : : : Declarative programming and inputoutput : : : : : : : : : : : : : : IO in functional languages : : : : : : : : : : : : : : : : : : : : : : What is a Fudget : : : : : : : : : : : : : : : : : : : : : : : : : : : : Contributions of the thesis : : : : : : : : : : : : : : : : : : : : : : : Roadmap : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : II Programming with Fudgets A brief intro duction to Haskell : : : : : : : : : : : : : : : : : : : : : Your rst Fudget programs : : : : : : : : : : : : : : : : : : : : : : Fudget library GUI elements : : : : : : : : : : : : : : : : : : : : : : Sp ecifying layout : : : : : : : : : : : : : : : : : : : : : : : : : : : : Abstract fudgets : : : : : : : : : : : : : : : : : : : : : : : : : : : : Fudget plumbing : : : : : : : : : : : : : : : : : : : : : : : : : : : : Fudgets for nonGUI IO : : : : : : : : : : : : : : : : : : : : : : : : Parameters for customisation : : : : : : : : : : : : : : : : : : : : : III Stream pro cessors the essence of Fudgets Stream pro cessors : : : : : : : : : : : : : : : : : : : : : : : : : : : : Plumbing comp osing stream pro cessors : : : : : : : : : : : : : : : Pragmatic asp ects of plumbing : : : : : : : : : : : : : : : : : : : : Application programming with plain stream pro cessors : : : : : : : IV Design and implementation Implementing stream pro cessors : : : : : : : : : : : : : : : : : : : : Fudgets as stream pro cessors : : : : : : : : : : : : : : : : : : : : : : Fudget IO the gory details : : : : : : : : : : : : : : : : : : : : : : Automatic layout : : : : : : : : : : : : : : : : : : : : : : : : : : : : Filter fudgets : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : Moving stream pro cessors : : : : : : : : : : : : : : : : : : : : : : : Typ ed so ckets for clientserver applications : : : : : : : : : : : : : Displaying and manipulating graphical ob jects : : : : : : : : : : : : CONTENTS Combinators for syntaxoriented manipulation : : : : : : : : : : : : Typ e directed GUI generation : : : : : : : : : : : : : : : : : : : : : Parameters for customisation : : : : : : : : : : : : : : : : : : : : : Gadgets in Fudgets : : : : : : : : : : : : : : : : : : : : : : : : : : : V Applications WWWBrowser a WWW client : : : : : : : : : : : : : : : : : : : Alfa a pro of editor for typ e theory
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages263 Page
-
File Size-