A technical report version is also available, which includes a formal presentation of the type system. 20 pages. Dec 2001. [letter ps] [letter pdf]
A prototype compiler based on the ideas of the paper is available from the GHC public CVS server under the directory hx. See the GCH CVS cheat sheet for instructions on how to access this repository.
Abstract
Though Haskell's module language is quite weak, its core language is highly expressive. Indeed, it is tantalisingly close to being able to express much of the structure traditionally delegated to a seperate module language. However, the encodings are awkward, and some situations can't be encoded at all.In this paper we refine Haskell's core language to support first-class modules with many of the features of ML-style modules. Our proposal cleanly encodes signatures, structures and functors with the appropriate type abstraction and type sharing, and supports recursive modules. All of these features work across compilation units, and interact harmoniously with Haskell's class system. Coupled with support for staged computation, we believe our proposal would be an elegant approach to run-time dynamic linking of structured code.
Our work builds directly upon Jones' work on parameterised signatures, Odersky and Laufer's system of higher-ranked type annotations, Russo's semantics of ML modules using ordinary existential and universal quantification, and Odersky and Zenger's work on nested types. We motivate the system by examples, and include a more formal presentation in the appendix.