Hostname: page-component-848d4c4894-nmvwc Total loading time: 0 Render date: 2024-06-24T17:06:22.217Z Has data issue: false hasContentIssue false

The ins and outs of Clean I/O

Published online by Cambridge University Press:  07 November 2008

Peter Achten
Affiliation:
Computing Science Institute, University of Nijmegen, 1 Toernooiveld, 6525ED, Nijmegen, The Netherlands (e-mail: peter88@cs.kun.nl)
Rinus Plasmeijer
Affiliation:
Computing Science Institute, University of Nijmegen, 1 Toernooiveld, 6525ED, Nijmegen, The Netherlands (e-mail: peter88@cs.kun.nl)
Rights & Permissions [Opens in a new window]

Abstract

Core share and HTML view are not available for this content. However, as you have access to this content, a full PDF is available via the ‘Save PDF’ action button.

Functional programming languages have banned assignment because of its undesirable properties. The reward of this rigorous decision is that functional programming languages are side-effect free. There is another side to the coin: because assignment plays a crucial role in Input/Output (I/O), functional languages have a hard time dealing with I/O. Functional programming languages have therefore often been stigmatised as inferior to imperative programming languages because they cannot deal with I/O very well. In this paper, we show that I/O can be incorporated in a functional programming language without loss of any of the generally accepted advantages of functional programming languages. This discussion is supported by an extensive account of the I/O system offered by the lazy, purely functional programming language Clean. Two aspects that are paramount in its I/O system make the approach novel with respect to other approaches. These aspects are the technique of explicit multiple environment passing, and the Event I/O framework to program Graphical User I/O in a highly structured and high-level way. Clean file I/O is as powerful and flexible as it is in common imperative languages (one can read, write, and seek directly in a file). Clean Event I/O provides programmers with a high-level framework to specify complex Graphical User I/O. It has been used to write applications such as a window-based text editor, an object based drawing program, a relational database, and a spreadsheet program. These graphical interactive programs are completely machine independent, but still obey the look-and-feel of the concrete window environment being used. The specifications are completely functional and make extensive use of uniqueness typing, higher-order functions, and algebraic data types. Efficient implementations are present on the Macintosh, Sun (X Windows under Open Look) and PC (OS/2).

Type
Articles
Copyright
Copyright © Cambridge University Press 1995

References

Achten, P. M., van Groningen, J. H. G. and Plasmeijer, M. J. (1993) High level specification of I/O in functional languages. In: Launchbury, J., Sansom, P. (eds.) Proc. Glasgow Workshop on Functional Programming, Ayr, Scotland, 6–8 June. (Workshop Notes in Computer Science. Springer-Verlag, 1993, pp. 117.)Google Scholar
Achten, P. M. and Plasmeijer, M. J. (1993) The beauty and the beast. Technical Report No. 93–03, March 1993. Research Institute for Declarative Systems, Department of Informatics, Faculty of Mathematics and Informatics, University of Nijmegen.Google Scholar
Achten, P. M. (1994) Operational semantics of Clean Event I/O. Technical Report (in preparation). University of Nijmegen, The Netherlands.Google Scholar
Backus, J. (1978) Can programming be liberated from the von Neuman style? A functional style and its algebra of programs. Communications of the ACM, 21 (8): 613641.CrossRefGoogle Scholar
Backus, J., Williams, J. and Wimmers, E. (1990) An introduction to the programming language FL. In Turner, D. A. (ed.) Research Topics in Functional Programming. Addison-Wesley, pp. 219247.Google Scholar
Barendregt, H. P., Eekelen van, M. C. J. D., Glauert, J. R. W., Kennaway, J. R., Plasmeijer, M. J. and Sleep, M. R. (1987) Term graph rewriting. In Bakker, J. W. de, Nijman, A. J., Treleaven, P. C. (eds.) Proc. Parallel Architectures and Languages Europe, Eindhoven, The Netherlands. (LNCS 259, Vol. II. Springer-Verlag, pp. 141158.)CrossRefGoogle Scholar
Barendsen, E. and Smetsers, J. E. W. (1993a) Conventional and uniqueness typing in graph rewrite systems. Technical Report CSI-R9328, Computing Science Institute, Department of Informatics, University of Nijmegen.CrossRefGoogle Scholar
Barendsen, E. and Smetsers, J. E. W. (1993b) Conventional and uniqueness typing in graph rewrite systems (extended abstract). In Shyamasundar, R. K. (ed.) Proc. Thirteenth Conf. Foundations of Software Technology and Theoretical Computer Science, 15–17 December, Bombay, India. (LNCS 761, Springer-Verlag, pp. 4151.)CrossRefGoogle Scholar
Brus, T., Eekelen, M. C. J. D. van, Leer, M. O. van and Plasmeijer, M. J. (1987) Clean: a language for functional graph rewriting. In Kahn, G. (ed.) Proc. Third Int. Conf. Functional Programming Languages and Computer Architecture, Portland, Oregon, USA. (LNCS 274, Springer-Verlag, pp. 364384.)CrossRefGoogle Scholar
Carlsson, M. and Hallgren, Th. (1993) fudgets – a graphical user interface in a lazy functional language. Proc. Conf. Functional Programming Languages and Computer Architecture. Copenhagen, Denmark, 911 June, ACM Press, pp. 321330.Google Scholar
Chirimar, J., Gunter, C. A. and Riecke, J. C. (1992) Proving memory management invariants for a language based on linear logic. Proc. ACM Conf. Lisp and Functional Programming, San Francisco, CA, June 22–24, ACM Press, pp. 139150.Google Scholar
Dwelly, A. (1989) Functions and dynamic user interfaces. Proc. Fourth Int. Conf. Functional Programming Languages and Computer Architecture, London, UK, September 11–13, pp. 371381.Google Scholar
Eekelen, M. C. J. D. van, Huitema, H. S., Nöcker, E. G. J. M. H., Plasmeijer, M. J. and Smetsers, J. E. W. (1993) Concurrent Clean language manual – Version 0.8. Technical Report No. 93–13. Research Institute for Declarative Systems, Department of Informatics, University of Nijmegen.Google Scholar
Girard, J.-Y. (1987) Linear logic. Theoretical Computer Science, 50: 1102.CrossRefGoogle Scholar
Gordon, A. D. (1993) Functional programming and input/output. PhD thesis, University of Cambridge Computer Laboratory, Technical Report No. 285.Google Scholar
Guzmán, J. C. and Hudak, P. (1990) Single-Threaded Polymorphic Lambda Calculus. Proc. Fifth Ann. IEEE Symposium on Logic in Computer Science. Philadelphia, PA June 4–7, pp. 333343.Google Scholar
Groningen, J. H. G. van, Nöcker, E. G. J. M. H. and Smetsers, J. E. W. (1991) Efficient heap management in the concrete ABC machine. In Glaser, , Hartel, (eds.) Proc. Third Int. Workshop on Implementation of Functional Languages on Parallel Architectures, Southampton, UK, Technical Report Series CSTR 91–07.Google Scholar
Henderson, P. (1982) Purely functional operating systems. In Darlington, J., Henderson, P., Turner, D. A. (eds.) Functional Programming and its Applications, Cambridge University Press, pp. 177192.Google Scholar
Hudak, P., Peyton Jones, S., Wadler, Ph., Boutel, B., Fairbairn, J., Fasel, J., Hammond, K., Hughes, J., Johnsson, Th., Kieburtz, D., Nikhil, R., Partain, W. and Peterson, J. (1992) Report on the programming language Haskell. ACM SigPlan Notices, 27 (5): 1164.Google Scholar
Hughes, J. (1990) Why functional programming matters. In Turner, D. A. (ed), Research Topics in Functional Programming. Addison-Wesley, pp. 1742.Google Scholar
Moggi, E. (1989) Computational lambda calculus and monads. Proc. Fourth Ann. Symposium on Logic in Computer Science, June 5–8, Computer Society Press, pp. 1423.CrossRefGoogle Scholar
Nöcker, E. G. J. M. H., Smetsers, J. E. W., van Eekelen, M. C. J. D. and Plasmeijer, M. J. (1991) Concurrent Clean. In Aarts, E. H. L., van Leeuwen, J., Rem, M. (eds.) Proc. Parallel Architectures and Languages Europe, June, Eindhoven, The Netherlands. (LNCS 506, Springer-Verlag, pp. 202219.)CrossRefGoogle Scholar
Perry, N. (1988) Functional I/O – a solution. Department of Computing, Imperial College, London (Draft).Google Scholar
Peyton Jones, S. L. and Wadler, Ph. (1993) Imperative functional programming. Proc. Twentieth Ann. ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages. Charleston, SC, January 10–13, pp. 7184.CrossRefGoogle Scholar
Plasmeijer, M. J. and van Eekelen, M. C. J. D. (1993) Functional Programming and Parallel Graph Rewriting. Addison-Wesley.Google Scholar
Plasmeijer, M. J. and van Eekelen, M. C. J. D. (1994) Clean 1.0 Reference Manual, Technical Report (in preparation) University of Nijmegen, The Netherlands.Google Scholar
Redelmeier, D. H. (1984) Towards practical functional programming. PhD thesis, Computer Systems Research Group, University of Toronto, May (Technical Report CSRG-158).Google Scholar
Smetsers, J. E. W., Nöcker, E. G. M. H., van Groningen, J. H. G. and Plasmeijer, M. J. (1991) Generating efficient code for lazy functional languages. In Hughes, J. (ed.) Proc. Fifth Int. Conf. on Functional Programming Languages and Computer Architecture, Cambridge, MA. (LNCS 523, Springer-Verlag, pp. 592617.)CrossRefGoogle Scholar
Smetsers, J. E. W., Barendsen, E., van Eekelen, M. C. J. D. and Plasmeijer, M. J. (1993) Guaranteeing safe destructive updates through a type system with uniqueness information for graphs. Proc. Workshop Graph Transformations in Computer Science, Schloss Dagstuhl, January 4–8. (Lecture Notes in Computer Science, Springer-Verlag).Google Scholar
Thompson, S. (1990) Interactive functional programs. A method and a formal semantics. In Turner, D. A. (ed.) Research Topics in Functional Programming, Addison-Wesley, pp. 249285.Google Scholar
Turner, D. A. (1990) An approach to functional operating systems. In Turner, D. A. (ed.) Research Topics in Functional Programming, Addison-Wesley, pp. 199217.Google Scholar
Wadler, Ph. (1990a) Linear types can change the world! In Broy, M., Jones, C. B. (eds.) Programming Concepts and Methods. North-Holland.Google Scholar
Wadler, Ph. (1990b) Comprehending monads. Proc. ACM Conf. Lisp and Functional Programming, ACM Press, pp. 6178.Google Scholar
Williams, J. H. and Wimmers, E. L. (1988) Sacrificing simplicity for convenience: Where do you draw the line? Proc. Fifteenth Ann. ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages, San Diego, CA, January, pp. 169179.CrossRefGoogle Scholar
Submit a response

Discussions

No Discussions have been published for this article.