Type-Secure Meta-Programming

Chris Dornan, Type-Secure Meta-Programming. PhD thesis. Department of Computer Science, University of Bristol. July 1998. PDF, 804 Kbytes.


This dissertation considers a new approach to embedding dynamic-typing facilities in a statically-typed functional programming language like ML, Miranda and Haskell. Currently, functional programs are limited by I/O systems that force them to convert their data structures to and from streams of characters. However, an effective dynamic-type mechanism would help functional programming to break out of this word-at-a-time mode of I/O, by facilitating the direct storage and transmission of application data structures, making possible, for example, the communication of polymorphic functions between processes or the storage of lazy data structures in file stores. A dynamic-type mechanism is needed here to enable the input and processing of arbitrarily-typed objects into running programs in order to prevent the (statically-typed) program from going wrong. The problem with existing dynamic-type proposals is that they are either too weak (they do not support polytypes) or, as their authors admit, they are rather complicated. The proposal of this dissertation is based on a simple and efficient tag comparison scheme that takes account of polymorphic types and interacts cleanly with the main type-abstraction mechanisms used in functional programming. This scheme is founded on an old idea from languages like SASL and LISP with exclusively dynamic typing disciplines. The scheme is based on the ML type system, extended with polymorphic function arguments. Such a type system is outlined, a proposal that introduces little that is not already to be found, in essence, in established type systems and compilers. The type system is integrated into a substantial subset of the Haskell programming language before showing how the system can be applied to a number of systems programming applications. A run-time compiler interface, a mechanism for meta-programs to construct, execute and analyse object-level programs, provides significant technical challenges for such a type system and it forms the focus of the dissertation. The run-time compiler interface entails the replacement of a static view of modules with a dynamic module store, but this system is shown to be sound my mapping it back onto the static module system.

Bibtex entry.

Publication Admin