Years of Citing Articles

Bookmark

OpenURL

Abstract

. Graphical user interfaces (GUIs) are hard to combine with functional programming. Using a suitable combination of monads, we are able to tame the imperative aspects of graphical I/O in a straightforward and elegant way. We present a concept to integrate lightweight GUIs into the functional framework, together with a library of basic functions and layout combinators to manipulate the GUI. An implementation of this library, using a set of high-level graphical I/O routines, is outlined. Examples demonstrate the simple way in which applications can be written. 1 Introduction Everybody wants to use graphical user interfaces. And everybody wants to use functional programming languages. Unfortunately, these concepts are hard to combine: I/O, and graphical I/O in particular, is imperative in nature, and thus contradictory to the functional paradigm. Our goal is to reconcile these two concepts, by developing a framework in which a functional programmer smoothly can provide his program with a...

Citations

...ublished, e.g., [Wad92, JD93, KL94, LPJ94, Wad94]. In general, a monad serves to record side-effects of functions. A good example is the I/O monad as it is implemented in the Glasgow Haskell compiler =-=[PJW93]-=- --- and recently laid down in the new definition of the Haskell language --- and in the Gofer language [Jon93b]. Another one is the State Reader monad that enables the user to thread the reading of a...

...o. This makes monads the natural choice for our system. For the implementation of graphical I/O we have deliberately chosen not to reinvent the wheel, but to use an existing high quality tool, Tcl/Tk =-=[Ous94]-=-, instead. This tool visualizes the user interface and handles events from the console and it communicates with the functional program in the form of strings. Thus we have reduced, on the side of the ...

...g them between backquotes, and the use of placeholders &quot; for values that are discarded. 2 Monads Since the seminal work of Moggi [Mog89], monads have become increasingly popular. After Wadler's p=-=aper [Wad90]-=- on their use in functional programming, numerous applications have been published, e.g., [Wad92, JD93, KL94, LPJ94, Wad94]. In general, a monad serves to record side-effects of functions. A good exam...

...stractions&quot;x-? , the use of function names as infix operators by placing them between backquotes, and the use of placeholders &quot; for values that are discarded. 2 Monads Since the seminal work=-= of Moggi [Mog89]-=-, monads have become increasingly popular. After Wadler's paper [Wad90] on their use in functional programming, numerous applications have been published, e.g., [Wad92, JD93, KL94, LPJ94, Wad94]. In g...

... with the primitive functions putchar :: Char -? IO () getch :: IO Char for writing and reading of characters. Secondly, we need some means of storing a state. Therefore, we use the mutable variables =-=[LPJ94]-=- as defined in Glasgow Haskell and Gofer, which also act on the IO monad. 1 A mutable variable is manipulated with the functions newVar :: a -? IO (Var a) readVar :: Var a -? IO a writeVar :: Var a -?...

...library with primitives similar to those of the Macintosh Toolbox, and implemented this GUI as a part of their runtime system. A rather different approach was presented by M. Carlsson and T. Hallgren =-=[CH93]-=-. Instead of using the traditional widgets, they proposed fudgets as a functional equivalent. Fudgets may be thought as processes having two streams between them: one for high-level messages, connecte...

...unctional program in the form of strings. Thus we have reduced, on the side of the functional program, graphical I/O to textual I/O --- for which I/O primitives are provided in, e.g., Glasgow Haskell =-=[HPJW92]-=- and Gofer [Jon93b]. We define a library of functions for manipulating the GUI. The programmer can write the GUI for his application in a structured and well-defined way, without having knowledge of t...

...n the form of strings. Thus we have reduced, on the side of the functional program, graphical I/O to textual I/O --- for which I/O primitives are provided in, e.g., Glasgow Haskell [HPJW92] and Gofer =-=[Jon93b]-=-. We define a library of functions for manipulating the GUI. The programmer can write the GUI for his application in a structured and well-defined way, without having knowledge of the tool used. Also,...

...s not asserted that the GUI representation in Miranda is used single threaded, whereas our monadic framework ensures this. An alternative solution to this last problem was proposed by the Clean group =-=[AvGP93]-=-, in the form of unique types. A unique type is guaranteed to be used only single threaded. Thus, the danger of copying GUIs is avoided. They developed a library with primitives similar to those of th...

... a continuation style. Although this approach is rather nice, it has some shortcomings too. Problems mainly concern the inherent combination of stream based coupling and visualization of widgets (cf. =-=[RS93]-=-). A work that also picks up Tcl/Tk as its GUI basics was already presented by D.C. Sinclair [Sin93]. He proposes to combine Haskell and Tcl/Tk using pipes, too. However, he does not hide Tcl/Tk behin...

...se to C and the Unix shell. Tcl is an embeddable language, i.e., the language is in fact a library, designed to be linked together with other applications. Tk. Tk is a toolkit for the X Window System =-=[SG86]-=- based on Tcl. It offers a set of widget commands for the creation of Motif-like user interfaces. All of the functionality of Tk-based applications is available through Tcl, i.e., evaluation of X even...

...s mainly concern the inherent combination of stream based coupling and visualization of widgets (cf. [RS93]). A work that also picks up Tcl/Tk as its GUI basics was already presented by D.C. Sinclair =-=[Sin93]-=-. He proposes to combine Haskell and Tcl/Tk using pipes, too. However, he does not hide Tcl/Tk behind the curtain --- as we do --- but uses a command-line oriented protocol between both processes. Bas...

... for a long time. We consider here only research to integrate GUIs in functional languages in a referential transparent way. Among the first who integrated a GUI in a functional language was S. Singh =-=[Sin92]-=-. This approach already used a back to back arrangement, i.e., the application, written in Miranda, and the GUI, written in C, communicate over pipes. Both sides of the pipe supply primitive interpret...

...o, bind replaces function application which is reflected by the monad laws : bind must be associative, and result is its left and right identity. In this paper, we use the do notation as described by =-=[Jon93a]. An expre-=-ssion do fe1; x !- e2; e3g replaces the equivalent e1 `bind` &quot; -? e2 `bind` &quot;x -? e3, i.e., the subexpression x !- e2 binds x to the result of e2, whereas the result of subexpression e1 is d...

...more, we showed how structured functional code is achievable using this approach. The disadvantage, however, remains that we had to program the user interface itself in pure Tcl/Tk. Lastly, Caml Light=-=[PR94]-=- was also linked to Tcl/Tk, but in a purely imperative way. 7 Conclusion In this paper, we presented a referential transparent functional library to develop modular applications with a lightweight gra...

...es not hide Tcl/Tk behind the curtain --- as we do --- but uses a command-line oriented protocol between both processes. Basically the same approach as Sinclair's was pursued in our own previous work =-=[SV94]-=-. However, we did not have to modify the Tcl shell as he did. Furthermore, we showed how structured functional code is achievable using this approach. The disadvantage, however, remains that we had to...