Hostname: page-component-78c5997874-lj6df Total loading time: 0 Render date: 2024-11-06T06:11:53.111Z Has data issue: false hasContentIssue false

1ML – Core and modules united

Published online by Cambridge University Press:  27 December 2018

ANDREAS ROSSBERG*
Affiliation:
Dfinity Foundation, Munich, Germany (e-mail: [email protected])
Rights & Permissions [Opens in a new window]

Abstract

Core share and HTML view are not available for this content. However, as you have access to this content, a full PDF is available via the ‘Save PDF’ action button.

ML is two languages in one: there is the core, with types and expressions, and there are modules, with signatures, structures, and functors. Modules form a separate, higher-order functional language on top of the core. There are both practical and technical reasons for this stratification; yet, it creates substantial duplication in syntax and semantics, and it imposes seemingly unnecessary limits on expressiveness because it makes modules second-class citizens of the language. For example, selecting one among several possible modules implementing a given interface cannot be made a dynamic decision. Language extensions allowing modules to be packaged up as first-class values have been proposed and implemented in different variations. However, they remedy expressiveness only to some extent and tend to be even more syntactically heavyweight than using second-class modules alone. We propose a redesign of ML in which modules are truly first-class values, and core and module layers are unified into one language. In this “1ML”, functions, functors, and even type constructors are one and the same construct; likewise, no distinction is needed between structures, records, or tuples. Or viewed the other way round, everything is just (“a mode of use of”) modules. Yet, 1ML does not require dependent types: its type structure is expressible in terms of plain System Fω, with a minor variation of our F-ing modules approach. We introduce both an explicitly typed version of 1ML and an extension with Damas–Milner-style implicit quantification. Type inference for this language is not complete, but, we argue, not substantially worse than for Standard ML.

Type
Research Article
Copyright
© Cambridge University Press 2018 

References

Barendregt, H. (1992) Lambda calculi with types. In Handbook of Logic in Computer Science, Abramsky, S., Gabbay, D. & Maibaum, T. S. E. (eds), vol. 2, Chap. 2. Oxford University Press, pp. 117309.Google Scholar
Biswas, S. K. (1995) Higher-order functors with transparent signatures. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL). ACM, pp. 154–163.CrossRefGoogle Scholar
Damas, L. & Milner, R. (1982) Principal type-schemes for functional programs. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL). ACM, pp. 207–212.CrossRefGoogle Scholar
Dreyer, D. (2005) Understanding and Evolving the ML Module System. PhD thesis, Carnegie Mellon University.Google Scholar
Dreyer, D. (2007) Recursive type generativity. J. Funct. Program. 17(4&5), 433471.CrossRefGoogle Scholar
Dreyer, D. & Blume, M. (2007) Principal type schemes for modular programs. In European Symposium on Programming (ESOP). LNCS, vol. 4421. Springer, pp. 441–457.CrossRefGoogle Scholar
Dreyer, D., Crary, K. & Harper, R. (2003) A type system for higher-order modules. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL). ACM, pp 236–149.CrossRefGoogle Scholar
Dreyer, D., Harper, R. & Chakravarty, M. (2007) Modular type classes. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL). ACM, pp 63–70.CrossRefGoogle Scholar
Garrigue, J. & Frisch, A. (2010) First-class modules and composable signatures in Objective Caml 3.12. In ACM SIGPLAN Workshop on ML. Accessed December 11, 2018. Available at: https://www.math.nagoya-u.ac.jp/~garrigue/papers/ml2010-show.pdf.Google Scholar
Garrigue, J. & Rémy, D. (1999) Semi-explicit first-class polymorphism for ML. Inf. Comput., 155(1–2), pp 134169.CrossRefGoogle Scholar
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 (POPL). ACM, pp 123–137.CrossRefGoogle Scholar
Harper, R. & Mitchell, J. C. (1993) On the type structure of Standard ML. ACM Trans. Program. Lang. Syst. 15(2), 211252.CrossRefGoogle Scholar
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 (POPL). ACM, pp 341–354.CrossRefGoogle Scholar
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), Chap. 8. MIT Press.Google Scholar
Harper, R. & Stone, C. (2000) A type-theoretic interpretation of Standard ML. In Proof, Language, and Interaction: Essays in Honor of Robin Milner, Gordon, D. Plotkin, Colin, S., & Mads, T. (eds), . MIT Press, pp. 341388.Google Scholar
Kuan, G. & MacQueen, D. (2009) Engineering higher-order modules in SML/NJ. In International Symposium on the Implementation and Application of Functional Languages (IFL). LNCS, vol. 6041, pp. 218–235.Google Scholar
Le Botlan, D. & Rémy, D. (2003) MLF: Raising ML to the power of System F. In ACM SIGPLAN International Conference on Functional Programming (ICFP). ACM, pp. 52–63.CrossRefGoogle Scholar
Leroy, X. (1994) Manifest types, modules, and separate compilation. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL). ACM, pp. 109–122.CrossRefGoogle Scholar
Leroy, X. (1995) Applicative functors and fully transparent higher-order modules. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL). ACM, pp. 142–153.CrossRefGoogle Scholar
Leroy, X. (1996) A syntactic theory of type generativity and sharing. J. Funct. Program. 6(5), 132.CrossRefGoogle Scholar
Lillibridge, M. (1997) Translucent Sums: A Foundation for Higher-order Module Systems. PhD thesis, Carnegie Mellon University.Google Scholar
MacQueen, D. B. (1986) Using dependent types to express modular structure. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL). ACM, pp. 277–286.CrossRefGoogle Scholar
MacQueen, D. B. & Tofte, M. (1994) A semantics for higher-order functors. In European Symposium on Programming (ESOP). Springer, pp. 409–423.CrossRefGoogle Scholar
Mahboubi, A. & Tassi, E. (2013) Canonical structures for the working Coq user. In Interactive Theorem Proving, Blazy, S., Paulin-Mohring, C. & Pichardie, D. (eds), LNCS, no. 7998. Springer-Verlag, pp. 1934.CrossRefGoogle Scholar
McBride, C. & Paterson, R. (2008) Applicative programming with effects. J. Funct. Program. 18(1), 113.CrossRefGoogle Scholar
Milner, R. (1978) A theory of type polymorphism in programming languages. J. Comput. Syst. Sci. 17, 348375.CrossRefGoogle Scholar
Milner, R., Tofte, M., Harper, R. & MacQueen, D. (1997) The Definition of Standard ML (Revised). MIT Press.Google Scholar
Mitchell, J. C. & Plotkin, G. D. (1988) Abstract types have existential type. ACM Trans. Program. Lang. Syst. 10(3), 470502.CrossRefGoogle Scholar
Odersky, M. & Zenger, M. (2005) Scalable component abstractions. In Object-Oriented Programming, Systems, Languages and Applications (OOPSLA). ACM Press, pp. 4157.Google Scholar
Ohori, A. (1995) A polymorphic record calculus and its compilation. ACM Trans. Program. Lang. Syst. 17(6), 844895.CrossRefGoogle Scholar
Rémy, D. (1989) Type checking records and variants in a natural extension of ML. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL). ACM, pp. 77–88.CrossRefGoogle Scholar
Rossberg, A. (1999a) Defects in the Revised Definition of Standard ML. Technical report, Max Planck Institute for Software Systems. Accessed December 11, 2018. Available at: mpi-sws.org/~rossberg/sml-defects.html.Google Scholar
Rossberg, A. (1999b) Undecidability of OCaml Type Checking. Posting to Caml mailing list, 13 July. Accessed December 11, 2018. Available at: sympa.inria.fr/sympa/arc/caml-list/1999-07/msg00027.html.Google Scholar
Rossberg, A. (2006) The missing link – Dynamic components for ML. In ACM SIGPLAN International Conference on Functional Programming (ICFP). ACM, pp. 99–110.Google Scholar
Rossberg, A. (2015) 1ML– Core and Modules United (Technical Appendix). Accessed December 11, 2018. Available at: mpi-sws.org/~rossberg/1ml/.Google Scholar
Rossberg, A. (2016) 1ML with special effects. In A List of Successes that Can Change the World – WadlerFest 2016. LNCS, no. 9600. Springer-Verlag, pp. 336–355.CrossRefGoogle Scholar
Rossberg, A. & Dreyer, D. (2013) Mixin’ up the ML module system. ACM Trans. Program. Lang. Syst. 35(1), 184.CrossRefGoogle Scholar
Rossberg, A., Russo, C. & Dreyer, D. (2014) F-ing modules. J. Funct. Program. 24(5), 529607.CrossRefGoogle Scholar
Russo, C. V. (1999) Non-dependent types for Standard ML modules. In International Conference on Principles and Practice of Declarative Programming (PPDP). Springer, pp. 80–97.CrossRefGoogle Scholar
Russo, C. V. (2000) First-class structures for Standard ML. Nord. J. Comput. 7(4), 348374.Google Scholar
Russo, C. V. (2003) Types for modules. Electron. Notes Theor. Comput. Sci. 60, pp. 3421.CrossRefGoogle Scholar
Russo, C. V. & Vytiniotis, D. (2009) QML: Explicit first-class polymorphism for ML. In ACM SIGPLAN Workshop on ML. ACM, pp. 3–14.CrossRefGoogle Scholar
Shao, Z. (1999) Transparent modules with fully syntactic signatures. In ACM SIGPLAN International Conference on Functional Programming (ICFP). ACM, pp. 220–232.CrossRefGoogle Scholar
Shields, M. & Peyton Jones, S. (2002) First-class modules for Haskell. In International Workshop on Foundations of Object-Oriented Languages (FOOL). ACM, pp. 28–40.Google Scholar
Stone, C. A. & Harper, R. (2006) Extensional equivalence and singleton types. ACM Trans. Comput. Logic 7(4), 676722.CrossRefGoogle Scholar
Talpin, J.-P. & Jouvelot, P. (1992) Polymorphic type, region and effect inference. J. Funct. Program. 2(3), 245271.CrossRefGoogle Scholar
Vytiniotis, D., Weirich, S. & Peyton Jones, S. (2008) FPH: First-class polymorphism for Haskell. In ACM SIGPLAN International Conference on Functional Programming (ICFP). ACM, pp. 295–306.CrossRefGoogle Scholar
Wadler, P. & Blott, S. (1989) How to make ad-hoc polymorphism less ad hoc. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL). ACM, pp. 60–76.CrossRefGoogle Scholar
White, L., Bour, F. & Yallop, J. (2014) Modular implicits. In ACM SIGPLAN ML Family / OCaml Workshops, Kiselyov, O. & Garrigue, J. (eds), EPTCS, no. 198. ACM, pp. 22–63.Google Scholar
Wright, A. (1995) Simple imperative polymorphism. LISP Symb. Comput. (LASC) 8(4), 343356.CrossRefGoogle Scholar
Submit a response

Discussions

No Discussions have been published for this article.