Types for Modules

Abstract The programming language Standard ML is an amalgam of two, largely orthogonal, languages. The Core language expresses details of algorithms and data structures. The Modules language expresses the modular architecture of a software system. Both languages are statically typed, with their static and dynamic semantics specified by a formal definition. Over the past decade, Standard ML Modules has been the source of inspiration for much research into the type-theoretic foundations of modules languages. Despite these efforts, a proper type-theoretic understanding of its static semantics has remained elusive. In this thesis, we use Type Theory as a guideline to reformulate the unconventional static semantics of Modules, providing a basis for useful extensions to the Modules language. Our starting point is a stylised presentation of the existing static semantics of Modules, parameterised by an arbitrary Core language. We claim that the type-theoretic concepts underlying Modules are type parameterisation, type quantification and subtyping. We substantiate this claim by giving a provably equivalent semantics with an alternative, more type-theoretic presentation. In particular, we show that the notion of type generativity corresponds to existential quantification over types. In contrast to previous accounts, our analysis does not involve first-order dependent types. Our first extension generalises Modules to higher-order, allowing modules to take parameterised modules as arguments, and return them as results. We go beyond previous proposals for higher-order Modules by supporting a notion of type generativity. We give a sound and complete algorithm for type-checking higher-order Modules. Our second extension permits modules to be treated as first-class citizens of an ML-like Core language, greatly extending the range of computations on modules. Each extension arises from a natural generalisation of our type-theoretic semantics. This thesis also addresses two pragmatic concerns. First, we propose a simple approach to the separate compilation of Modules, which is adequate in practice but has theoretical limitations. We suggest a modified syntax and semantics that alleviates these limitations. Second, we study the type inference problem posed by uniting our extensions to higher-order and first-class modules with an implicitly-typed, ML-like Core language. We present a hybrid type inference algorithm that integrates the classical algorithm for ML with the type-checking algorithm for Modules.

[1]  Maria-Virginia Aponte Extending record typing to type parametric modules with sharing , 1993, POPL '93.

[2]  David B. MacQueen Using dependent types to express modular structure , 1986, POPL '86.

[3]  Xavier Leroy,et al.  A syntactic theory of type generativity and sharing , 1996, Journal of Functional Programming.

[4]  Butler W. Lampson,et al.  A Kernel Language for Abstract Data Types and Modules , 1984, Semantics of Data Types.

[5]  Douglas J. Howe,et al.  Impredicative Strong Existential Equivalent to Type:Type , 1986 .

[6]  Gérard P. Huet,et al.  A Unification Algorithm for Typed lambda-Calculus , 1975, Theor. Comput. Sci..

[7]  Luís Damas,et al.  Type assignment in programming languages , 1984 .

[8]  Donald Sannella,et al.  The Definition of Extended ML: A Gentle Introduction , 1997, Theor. Comput. Sci..

[9]  Judicaël Courant,et al.  A Module Calculus for Pure Type Systems , 1997, TLCA.

[10]  Butler W. Lampson,et al.  Pebble, a Kernel Language for Modules and Abstract Data Types , 1988, Inf. Comput..

[11]  Zhaohui Luo An extended calculus of constructions , 1990 .

[12]  François Pottier Implémentation d'un système de modules évolué en Caml-Light , 1995 .

[13]  Luca Cardelli,et al.  The Quest Language and System , 1994 .

[14]  Dale Miller,et al.  Unification Under a Mixed Prefix , 1992, J. Symb. Comput..

[15]  Mads Tofte,et al.  A Semantics for Higher-Order Functors , 1994, ESOP.

[16]  Luca Cardelli,et al.  Typeful Programming , 1989, Formal Description of Programming Concepts.

[17]  Haskell B. Curry,et al.  Combinatory Logic, Volume I , 1959 .

[18]  M. Lillibridge Translucent Sums: A Foundation for Higher-Order Module Systems , 1997 .

[19]  John C. Mitchell,et al.  Higher-order modules and the phase distinction , 1989, POPL '90.

[20]  Claudio V. Russo Standard ML Type Generativity as Existential Quantification , 1996 .

[21]  John C. Mitchell,et al.  Foundations for programming languages , 1996, Foundation of computing series.

[22]  Claudio V. Russo First-Class Structures for Standard ML , 2000, Nord. J. Comput..

[23]  Richard S. Bird,et al.  Generic functional programming with types and relations , 1996, Journal of Functional Programming.

[24]  M. Tofte Operational Semantics and Polymorphic Type Inference , 1988 .

[25]  James McKinna,et al.  Pure Type Systems Formalized , 1993, TLCA.

[26]  J. A. Robinson,et al.  A Machine-Oriented Logic Based on the Resolution Principle , 1965, JACM.

[27]  Robert Harper,et al.  An Interpretation of Standard ML in Type Theory , 1997 .

[28]  John C. Mitchell,et al.  Abstract types have existential types , 1985, POPL.

[29]  Judicaël Courant,et al.  An Applicative Module Calculus , 1997, TAPSOFT.

[30]  Luca Cardelli,et al.  Phase Distinctions in Type Theory , 1988 .

[31]  Sandip K. Biswas Higher-order functors with transparent signatures , 1995, POPL '95.

[32]  Simon Peyton Jones,et al.  An Exploration of Modular Programs , 1996 .

[33]  Xavier Leroy,et al.  Manifest types, modules, and separate compilation , 1994, POPL '94.

[34]  Simon Thompson,et al.  Type theory and functional programming , 1991, International computer science series.

[35]  Robert Harper,et al.  A Type-Theoretic Account of Standard ML 1996 (Version 1). , 1996 .

[36]  William A. Howard,et al.  The formulae-as-types notion of construction , 1969 .

[37]  T. Coquand An algorithm for testing conversion in type theory , 1991 .

[38]  Zhaohui Luo,et al.  ECC, an extended calculus of constructions , 1989, [1989] Proceedings. Fourth Annual Symposium on Logic in Computer Science.

[39]  John C. Mitchell,et al.  On the type structure of standard ML , 1993, TOPL.

[40]  Xavier Leroy,et al.  Applicative functors and fully transparent higher-order modules , 1995, POPL '95.

[41]  Robin Milner,et al.  A Theory of Type Polymorphism in Programming , 1978, J. Comput. Syst. Sci..

[42]  Robin Milner,et al.  Commentary on standard ML , 1990 .

[43]  de Ng Dick Bruijn Lambda calculus notation with nameless dummies, a tool for automatic formula manipulation, with application to the Church-Rosser theorem , 1972 .

[44]  Mark P. Jones,et al.  Using parameterized signatures to express modular structure , 1996, POPL '96.

[45]  Mads Tofte,et al.  Principal signatures for higher-order program modules , 1992, POPL '92.

[46]  Martin Elsman Program modules, separate compilation, and intermodule optimisation , 1999, Technical report / University of Copenhagen / Datalogisk institut.

[47]  Simon L. Peyton Jones,et al.  Type Classes in Haskell , 1994, ESOP.

[48]  Xavier Leroy,et al.  A modular module system , 2000, J. Funct. Program..

[49]  Mark Lillibridge,et al.  A type-theoretic approach to higher-order modules with sharing , 1994, POPL '94.

[50]  Luca Cardelli,et al.  Abstract Types and the Dot Notation , 1990, Programming Concepts and Methods.

[51]  Dale Miller,et al.  A Logic Programming Language with Lambda-Abstraction, Function Variables, and Simple Unification , 1991, J. Log. Comput..

[52]  Luca Cardelli,et al.  A Semantic Basis for Quest , 1991, J. Funct. Program..

[53]  Lawrence Charles Paulson,et al.  ML for the working programmer , 1991 .

[54]  Savi Maharaj,et al.  Studying the ML Module System in Hol , 1994, TPHOLs.

[55]  Robin Milner,et al.  Definition of standard ML , 1990 .

[56]  Niklaus Wirth,et al.  Programming in Modula-2 , 1985, Texts and Monographs in Computer Science.