Skip to main content
×
Home

F-ing modules

  • ANDREAS ROSSBERG (a1), CLAUDIO RUSSO (a2) and DEREK DREYER (a3)
Abstract
Abstract

ML modules are a powerful language mechanism for decomposing programs into reusable components. Unfortunately, they also have a reputation for being “complex” and requiring fancy type theory that is mostly opaque to non-experts. While this reputation is certainly understandable, given the many non-standard methodologies that have been developed in the process of studying modules, we aim here to demonstrate that it is undeserved. To do so, we present a novel formalization of ML modules, which defines their semantics directly by a compositional “elaboration” translation into plain System Fω (the higher-order polymorphic λ-calculus). To demonstrate the scalability of our “F-ing” semantics, we use it to define a representative, higher-order ML-style module language, encompassing all the major features of existing ML module dialects (except for recursive modules). We thereby show that ML modules are merely a particular mode of use of System Fω.

To streamline the exposition, we present the semantics of our module language in stages. We begin by defining a subset of the language supporting a Standard ML-like language with second-class modules and generative functors. We then extend this sublanguage with the ability to package modules as first-class values (a very simple extension, as it turns out) and OCaml-style applicative functors (somewhat harder). Unlike previous work combining both generative and applicative functors, we do not require two distinct forms of functor or signature sealing. Instead, whether a functor is applicative or not depends only on the computational purity of its body. In fact, we argue that applicative/generative is rather incidental terminology for pure versus impure functors. This approach results in a semantics that we feel is simpler and more natural than previous accounts, and moreover prohibits breaches of abstraction safety that were possible under them.

    • Send article to Kindle

      To send this article to your Kindle, first ensure no-reply@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about sending to your Kindle.

      Note you can select to send to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be sent to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

      Find out more about the Kindle Personal Document Service.

      F-ing modules
      Available formats
      ×
      Send article to Dropbox

      To send this article to your Dropbox account, please select one or more formats and confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your Dropbox account. Find out more about sending content to Dropbox.

      F-ing modules
      Available formats
      ×
      Send article to Google Drive

      To send this article to your Google Drive account, please select one or more formats and confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your Google Drive account. Find out more about sending content to Google Drive.

      F-ing modules
      Available formats
      ×
Copyright
References
Hide All
Ahmed A., Dreyer D. & Rossberg A. (2009) State-dependent representation independence. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 350353.
Atkey R. (2012) Relational parametricity for higher kinds. EACSL Annual Conference on Computer Science Logic, pp. 4661.
Aydemir B., Charguéraud A., Pierce B. C., Pollack R.. & Weirich S.. (2008) Engineering formal metatheory. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 315.
Aydemir B., Weirich S. & Zdancewic S.. (2009) Abstracting syntax. Technical report.
Biswas S. K. (1995) Higher-order functors with transparent signatures. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 154–163.
Cardelli L. & Leroy X.. (1990) Abstract types and the dot notation. In Programming Concepts and Methods, IFIP State of the Art Reports. North Holland, pp. 479504.
Coq Development Team. (2007) The Coq proof assistant reference manual. INRIA. Available at: http://coq.inria.fr/+.
Dreyer D. (2005) Understanding and Evolving the ML Module System. Ph.D. thesis, Carnegie Mellon University.
Dreyer D. (2007a) Recursive type generativity. J. Funct. Program. 17 (4–5), 433471.
Dreyer D. (2007b) A type system for recursive modules. In ACM SIGPLAN International Conference on Functional Programming, 289302.
Dreyer D. & Blume M.. (2007) Principal type schemes for modular programs. In European Symposium on Programming, pp. 441457.
Dreyer D., Crary K. & Harper R.. (2002) Moscow ML's higher-order modules are unsound. Posting to Types forum, 17 September.
Dreyer D., Crary K. & Harper R.. (2003) A type system for higher-order modules. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, 236249.
Elsman M. (1999) Program Modules, Separate Compilation, and Intermodule Optimisation. Ph.D. thesis, University of Copenhagen.
Geuvers H. (1992) The Church-Rosser property for βη-reduction in typed λ-calculi. In IEEE Symposium on Logic in Computer Science, 453460.
Ghelli G. & Pierce B.. (1998) Bounded existentials and minimal typing. Theor. Comput. Sci. 193 (1-2), 7596.
Goldfarb W.D. (1981) The undecidability of the second-order unification problem. Theor. Comput. Sci. 13, 225230.
Harper R. (2012) Programming in Standard ML. Available at: http://www.cs.cmu.edu/~rwh/smlbook/.
Harper R. & Lillibridge M.. (1994) A type-theoretic approach to higher-order modules with sharing. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, 123137.
Harper R. & Mitchell J. C. (1993) On the type structure of Standard ML. ACM Trans. Program. Lang. Syst. 15 (2), 211252.
Harper R., Mitchell J. C. & Moggi E.. (1990) Higher-order modules and the phase distinction. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, 341354.
Harper R. & Pierce B. C. (2005) Design considerations for ML-style module systems. In Advanced Topics in Types and Programming Languages, Pierce B. C. (ed), chapter 8, MIT.
Harper R. & Stone C.. (2000) A type-theoretic interpretation of Standard ML. In Proof, Language, and Interaction: Essays in Honor of Robin Milner, MIT, 341388.
Jones M. P. (1996) Using parameterized signatures to express modular structure. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, 68–78.
Kuan G. & MacQueen D.. (2010) Engineering higher-order modules in SML/NJ. In International Symposium on the Implementation and Application of Functional Languages. Lecture Notes in Computer Science, Volume 6041, 2010, pp 218235.
Launchbury J. & Peyton Jones S. L. (1995) State in Haskell. LISP Symbol. Comput. 8 (4), 293341.
Lee D. K., Crary K. & Harper R. (2007) Towards a mechanized metatheory of Standard ML. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, 173184.
Leifer J., Peskine G., Sewell P. & Wansbrough K. (2003) Global abstraction-safe marshalling with hash types. In ACM SIGPLAN International Conference on Functional Programming, 8798.
Leroy X. (1994) Manifest types, modules, and separate compilation. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, 109122.
Leroy X. (1995) Applicative functors and fully transparent higher-order modules. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, 142153.
Leroy X. (1996) A syntactic theory of type generativity and sharing. J. Funct. Program. 6 (5), 667698.
Leroy X. (2000) A modular module system. J. Funct. Program. 10 (3), 269303.
Lillibridge M. (1997) Translucent Sums: A Foundation for Higher-Order Module Systems. Ph.D. thesis, Carnegie Mellon University.
MacQueen D. B. (1986) Using dependent types to express modular structure. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, 277286.
MacQueen D. B. & Tofte M. (1994) A semantics for higher-order functors. In In European Symposium on Programming, 409423.
Milner R., Tofte M. & Harper R. (1990) The Definition of Standard ML, MIT.
Milner R., Tofte M., Harper R. & MacQueen D. (1997) The Definition of Standard ML (revised), MIT.
Mitchell J. C. & Plotkin G. D. (1988) Abstract types have existential type. ACM Trans. Program. Lang. Syst. 10 (3), 470502.
Montagu B. & Rémy D. (2009) Modeling abstract types in modules with open existential types. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, 354365.
Paulson L. C. (1996) ML for the Working Programmer, 2nd ed.Cambridge University Press.
Peyton Jones S. (2003) Wearing the hair shirt: a retrospective on Haskell. Invited talk, ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. Available at: http://research.microsoft.com/~simonpj.
Romanenko S., Russo C. V. & Sestoft P. (2000) Moscow ML Version 2.0. Available at: http://www.dina.kvl.dk/~sestoft/mosml.
Rossberg A. (1999) Undecidability of OCaml type checking. Posting to Caml mailing list, 13 July.
Rossberg A. & Dreyer D. (2013) Mixin' up the ML module system. ACM Trans. Lang. Syst. 35 (1), Article 2, 2:1–2:84.
Rossberg A., Le Botlan D., Tack G. & Smolka G. (2004) Alice through the looking glass. In Trends in Functional Programming, 7985.
Rossberg A., Russo C. V. & Dreyer D. (2010) F-ing modules. In ACM SIGPLAN Workshop on Types in Language Design and Implementation, 89102.
Russo C. V. (1998) Types for Modules. Ph.D. thesis, LFCS, University of Edinburgh.
Russo C. V. (1999) Non-dependent types for Standard ML modules. In International Conference on Principles and Practice of Declarative Programming, 8097.
Russo C. V. (2000) First-class structures for Standard ML. Nord. J. Comput. 7 (4), 348374.
Russo C. V. (2003) Types for modules. In Electronic Notes in Theoretical Computer Science, 60, 3421.
Sewell P., Leifer J. J., Wansbrough K., Zappa Nardelli F., Allen.-Williams M., Habouzit P. & Vafeiadis V. (2007) Acute: High-level programming language design for distributed computation. J. Funct. Program. 17 (4–5), 547612.
Shan C.-C. (2004) Higher-order modules in System Fω and Haskell. Technical Report. Available at: http://www.cs.rutgers.edu/~ccshan/xlate/xlate.pdf.
Shao Z. (1999) Transparent modules with fully syntactic signatures. In ACM SIGPLAN International Conference on Functional Programming, 220232.
Shields M. & Peyton Jones S. (2002) First-class modules for Haskell. In International Workshop on Foundations of Object-Oriented Language, pp. 2840.
SML/NJ Development Team (1993) Standard ML of New Jersey user's guide. 0.93 ed., AT&T Bell Laboratories.
Stone C. A. & Harper R. (2006) Extensional equivalence and singleton types. ACM Trans. Comput. Log. 7 (4), 676722.
Sulzmann M., Chakravarty M. M. T., Peyton Jones S. & Donnelly K. (2007) System F with type equality coercions. In ACM SIGPLAN Workshop on Types in Language Design and Implementation, 5366.
Torgersen M., Ernst E. & Hanser C. P. (2005) Wild FJ. In International Workshop on Foundations of Object-Oriented Languages, 115.
Wright A. (1995) Simple imperative polymorphism. In LISP and Symbolic Computation, pp. 343356.
Recommend this journal

Email your librarian or administrator to recommend adding this journal to your organisation's collection.

Journal of Functional Programming
  • ISSN: 0956-7968
  • EISSN: 1469-7653
  • URL: /core/journals/journal-of-functional-programming
Please enter your name
Please enter a valid email address
Who would you like to send this to? *
×

Metrics

Full text views

Total number of HTML views: 2
Total number of PDF views: 121 *
Loading metrics...

Abstract views

Total abstract views: 212 *
Loading metrics...

* Views captured on Cambridge Core between September 2016 - 21st November 2017. This data will be updated every 24 hours.