skip to main content
10.1145/1708016.1708028acmconferencesArticle/Chapter ViewAbstractPublication PagespoplConference Proceedingsconference-collections
research-article

F-ing modules

Published: 23 January 2010 Publication History

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 give a very simple elaboration semantics for a full-featured, higher-order ML-like module language. Our elaboration defines the meaning of module expressions by a straightforward, compositional translation into vanilla System F-ω (the higher-order polymorphic λ-calculus), under plain F-ω typing environments. We thereby show that ML modules are merely a particular mode of use of System F-ω.
Our module language supports the usual second-class modules with Standard ML-style generative functors and local module definitions. To demonstrate the versatility of our approach, we further extend the language with the ability to package modules as first-class values---a very simple extension, as it turns out. Our approach also scales to handle OCaml-style applicative functor semantics, but the details are significantly more subtle, so we leave their presentation to a future, expanded version of this paper.
Lastly, we report on our experience using the "locally nameless" approach in order to mechanize the soundness of our elaboration semantics in Coq.

References

[1]
B. Aydemir, A. Charguéraud, B. C. Pierce, R. Pollack, and S. Weirich. Engineering formal metatheory. In POPL '08.
[2]
B. Aydemir, S. Weirich, and S. Zdancewic. Abstracting syntax. Technical Report MS-CIS-09-06, U. Penn, 2009.
[3]
S. K. Biswas. Higher-order functors with transparent signatures. In POPL '95.
[4]
Coq Development Team. The Coq proof assistant reference manual, v. 8.1. INRIA, 2007. http://coq.inria.fr/.
[5]
D. Dreyer. A type system for recursive modules. In ICFP '07.
[6]
D. Dreyer. Understanding and Evolving the ML Module System. PhD thesis, CMU, 2005.
[7]
D. Dreyer. Recursive type generativity. JFP, 17(4&5):433--471, 2007.
[8]
D. Dreyer and M. Blume. Principal type schemes for modular programs. In ESOP'07.
[9]
D. Dreyer, K. Crary, and R. Harper. A type system for higher-order modules. In POPL '03.
[10]
D. Dreyer, K. Crary, and R. Harper. Moscow ML's higher-order modules are unsound, 17 September 2002. (Types Forum).
[11]
D. Dreyer and A. Rossberg. Mixin' up the ML module system. In ICFP '08.
[12]
M. Elsman. Program Modules, Separate Compilation, and Intermodule Optimisation. PhD thesis, U. of Copenhagen, 1999.
[13]
G. Ghelli and B. Pierce. Bounded existentials and minimal typing. TCS, 193(1-2):75--96, 1998.
[14]
W. D. Goldfarb. The undecidability of the second-order unification problem. Theoretical Computer Science, 13:225--230, 1981.
[15]
R. Harper. Programming in Standard ML. Working draft available at: http://www.cs.cmu.edu/~rwh/smlbook/.
[16]
R. Harper and M. Lillibridge. A type-theoretic approach to higherorder modules with sharing. In POPL '94.
[17]
R. Harper and J. C. Mitchell. On the type structure of Standard ML. In TOPLAS, volume 15(2), pages 211--252, 1993.
[18]
R. Harper, J. C. Mitchell, and E. Moggi. Higher-order modules and the phase distinction. In POPL '90.
[19]
R. Harper and B. Pierce. Design considerations for ML-style module systems. In B. C. Pierce, editor, Advanced Topics in Types and Programming Languages, chapter 8. MIT Press, 2005.
[20]
R. Harper and C. Stone. A type-theoretic interpretation of Standard ML. In Proof, Language, and Interaction: Essays in Honor of Robin Milner. MIT Press, 2000.
[21]
A. Igarashi, B. C. Pierce, and P. Wadler. Featherweight Java: A minimal core calculus for Java and GJ. TOPLAS, 23(3), 2001.
[22]
M. P. Jones. Using parameterized signatures to express modular structure. In POPL '96.
[23]
J. Launchbury and S. L. Peyton Jones. State in Haskell. Lisp and Symbolic Computation, 8(4):293--341, Dec. 1995.
[24]
D. K. Lee, K. Crary, and R. Harper. Towards a mechanized metatheory of Standard ML. In POPL '07.
[25]
X. Leroy. Applicative functors and fully transparent higher-order modules. In POPL '95.
[26]
X. Leroy. A syntactic theory of type generativity and sharing. JFP, 6(5):1--32, September 1996.
[27]
X. Leroy. A modular module system. JFP, 10(3):269--303, 2000.
[28]
M. Lillibridge. Translucent Sums: A Foundation for Higher-Order Module Systems. PhD thesis, CMU, 1997.
[29]
D. MacQueen. Using dependent types to express modular structure. In POPL '86.
[30]
D. MacQueen and M. Tofte. A semantics for higher-order functors. In ESOP '94.
[31]
R. Milner, M. Tofte, R. Harper, and D. MacQueen. The Definition of Standard ML (Revised). MIT Press, 1997.
[32]
J. C. Mitchell and G. D. Plotkin. Abstract types have existential type. TOPLAS, 10(3):470--502, July 1988.
[33]
B. Montagu and D. Rémy. Modeling abstract types in modules with open existential types. In POPL '09.
[34]
L. C. Paulson. ML for the Working Programmer, 2nd Edition. Cambridge University Press, 1996.
[35]
S. Peyton Jones. Wearing the hair shirt: a retrospective on Haskell. Invited talk, POPL '03.
[36]
C. V. Russo. Non-dependent types for Standard ML modules. In PPDP '99.
[37]
C. V. Russo. Types For Modules. PhD thesis, LFCS, University of Edinburgh, 1998.
[38]
C. V. Russo. First-class structures for Standard ML. Nordic Journal of Computing, 7(4):348--374, November 2000.
[39]
C. V. Russo. Types for Modules. ENTCS, 60, 2003. Chapter 10.
[40]
C. Shan. Higher-order modules in System F! and Haskell, 2004. http://www.cs.rutgers.edu/~ccshan/xlate/xlate.pdf.
[41]
Z. Shao. Transparent modules with fully syntactic signatures. In ICFP '99.
[42]
M. Shields and S. Peyton Jones. First-class modules for Haskell. In FOOL 9, 2002.
[43]
C. A. Stone and R. Harper. Extensional equivalence and singleton types. TOCL, 7(4):676--722, 2006.
[44]
M. Sulzmann, M. M. T. Chakravarty, S. Peyton Jones, and K. Donnelly. System F with type equality coercions. In TLDI '07.
[45]
M. Torgersen, E. Ernst, and C. P. Hanser. Wild FJ. In FOOL 12, 2005.

Cited By

View all

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
TLDI '10: Proceedings of the 5th ACM SIGPLAN workshop on Types in language design and implementation
January 2010
108 pages
ISBN:9781605588919
DOI:10.1145/1708016
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

Sponsors

In-Cooperation

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 23 January 2010

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. abstract data types
  2. elaboration
  3. existential types
  4. first-class modules
  5. ml modules
  6. system f
  7. type systems

Qualifiers

  • Research-article

Conference

POPL '10
Sponsor:

Acceptance Rates

Overall Acceptance Rate 11 of 26 submissions, 42%

Upcoming Conference

POPL '25

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)35
  • Downloads (Last 6 weeks)1
Reflects downloads up to 13 Jan 2025

Other Metrics

Citations

Cited By

View all
  • (2025)A Preliminary Type- and Control-Flow Analysis for System F$$_\omega $$Trends in Functional Programming10.1007/978-3-031-74558-4_8(160-194)Online publication date: 10-Jan-2025
  • (2024)Generic Reasoning of the Locally Nameless RepresentationProgramming Languages and Systems10.1007/978-981-97-8943-6_3(42-62)Online publication date: 23-Oct-2024
  • (2024)An ML-Style Module System for Cross-Stage Type Abstraction in Multi-stage ProgrammingFunctional and Logic Programming10.1007/978-981-97-2300-3_13(237-272)Online publication date: 2024
  • (2019)A Formalized General Theory of Syntax with Bindings: Extended VersionJournal of Automated Reasoning10.1007/s10817-019-09522-264:4(641-675)Online publication date: 16-Apr-2019
  • (2019)Incremental $$\lambda $$ -Calculus in Cache-Transfer StyleProgramming Languages and Systems10.1007/978-3-030-17184-1_20(553-580)Online publication date: 6-Apr-2019
  • (2016)Staging beyond terms: prospects and challengesProceedings of the 2016 ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation10.1145/2847538.2847548(103-108)Online publication date: 11-Jan-2016
  • (2016)Correctness of compiling polymorphism to dynamic typingJournal of Functional Programming10.1017/S095679681600026527Online publication date: 12-Dec-2016
  • (2016)Needle & KnotProceedings of the 25th European Symposium on Programming Languages and Systems - Volume 963210.1007/978-3-662-49498-1_17(419-445)Online publication date: 2-Apr-2016
  • (2014)BackpackACM SIGPLAN Notices10.1145/2578855.253588449:1(19-31)Online publication date: 8-Jan-2014
  • (2014)BackpackProceedings of the 41st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages10.1145/2535838.2535884(19-31)Online publication date: 11-Jan-2014
  • Show More Cited By

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media