University of Twente Student Theses

Login

Input/output in functional languages : using algebraic uniontTypes

Rorije, R.J. (2006) Input/output in functional languages : using algebraic uniontTypes.

[img] PDF
883kB
Abstract:Functional programming languages are not directly suitable to program I/O. In this thesis different models of I/O in functional languages are discussed with their advantages and disadvantages. Comparing these advantages and disadvantages results in the observation that the stream I/O-model is - at least from an educational point of view - the most appropriate model, because it does not create any new constructs to the language and the I/O-model is easy to understand. One problem in the stream I/O model is that event types in the form of algebraic types in the language are fixed. In this thesis I will show that it is possible to add a new type construction that can combine algebraic data types in untagged unions. The benefit of these unions is, that from the perspective of the programmer the union behaves as if it were defined as the list of all constructors of both types. Now the union can be used as a normal algebraic type. In order to add this union construct to a functional programming language, new typing rules must be introduced. Obviously subtyping is closely related to unions, since values of the constituents of a union are also values of the (composite) union. therefore subtyping rules must be added to the type system. It will be shown that using these type rules the intuitive notion of unions being commutative, associative and idempotent are preserved. To implement this union construct in a functional language, the language must be extended to handle union types. Therefore two rewriting schemes are given in this thesis. A naïve implementation for the language Amanda and a more extensive one using some features that are particular to Haskell. Lastly the use of unions in the stream I/O model is shown with two examples, one using the naÏve rewriting scheme and one using the more extensive rewriting scheme. In particular is shown that events can be defined separately in libraries and can the events from this libraries can be combined in a union to use them in a program.
Item Type:Essay (Master)
Faculty:EEMCS: Electrical Engineering, Mathematics and Computer Science
Subject:54 computer science
Programme:Computer Science MSc (60300)
Link to this item:https://purl.utwente.nl/essays/57287
Export this item as:BibTeX
EndNote
HTML Citation
Reference Manager

 

Repository Staff Only: item control page