Engineering Higher-Order Modules in SML/NJ

SML/NJ and other Standard ML variants extend the ML module system with higher-order functors, elevating the module language to a full functional language. In this paper, we describe the implementation of higher-order modules in SML/NJ, which is unique in providing "true" higher-order static behavior. This implementation is based on three key ideas: unique internal variables (entity variables) for naming static entities, factorization of the static information in both basic modules and functors into signatures and realizations, and representing the static "effects" and type-level mapping performed by a functor using a static lambda calculus (the entity calculus). This design conforms to MacQueen-Tofte's re-elaboration semantics without having to re-elaborate functor bodies at functor applications.

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

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

[3]  John C. Mitchell,et al.  Abstract types have existential type , 1988, TOPL.

[4]  Zhong Shao Transparent modules with fully syntatic signatures , 1999, ICFP '99.

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

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

[7]  Mark P. Jones,et al.  A formal specification of the Haskell 98 module system , 2002, Haskell '02.

[8]  X. Leroy Le système Caml Special Light: modules et compilation efficace en Caml , 1995 .

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

[10]  Matthew Flatt Composable and compilable macros:: you want it when? , 2002, ICFP '02.

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

[12]  Derek Dreyer A type system for recursive modules , 2007, ICFP '07.

[13]  Mike Paterson,et al.  Linear Unification , 1978, J. Comput. Syst. Sci..

[14]  Derek Dreyer,et al.  A type system for higher-order modules , 2003, POPL '03.

[15]  David MacQueen,et al.  A true higher-order module system , 2010 .

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

[17]  Norman Ramsey ML Module Mania: A Type-Safe, Separately Compiled, Extensible Interpreter , 2006, Electron. Notes Theor. Comput. Sci..

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

[19]  Jaakko Järvi,et al.  An extended comparative study of language support for generic programming , 2007, Journal of Functional Programming.

[20]  Didier Rémy,et al.  Modeling abstract types in modules with open existential types , 2009, POPL '09.

[21]  T Bell,et al.  An Implementation of Higher-Order FunctorsPierre Cr , 1994 .

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

[23]  Claudio V. Russo Types for Modules , 2004, Electronic Notes in Theoretical Computer Science.

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

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

[26]  Benjamin C. Pierce,et al.  Advanced Topics In Types And Programming Languages , 2004 .