Hostname: page-component-848d4c4894-nr4z6 Total loading time: 0 Render date: 2024-05-19T18:41:38.531Z Has data issue: false hasContentIssue false

Recursive type generativity

Published online by Cambridge University Press:  01 July 2007

DEREK DREYER*
Affiliation:
Toyota Technological Institute, Chicago, IL 60637, USA (e-mail: dreyer@tti-c.org)
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.

Existential types provide a simple and elegant foundation for understanding generative abstract data types of the kind supported by the Standard ML module system. However, in attempting to extend ML with support for recursive modules, we have found that the traditional existential account of type generativity does not work well in the presence of mutually recursive module definitions. The key problem is that, in recursive modules, one may wish to define an abstract type in a context where a name for the type already exists, but the existential type mechanism does not allow one to do so. We propose a novel account of recursive type generativity that resolves this problem. The basic idea is to separate the act of generating a name for an abstract type from the act of defining its underlying representation. To define several abstract types recursively, one may first ‘forward-declare’ them by generating their names, and then supply each one's identity secretly within its own defining expression. Intuitively, this can be viewed as a kind of backpatching semantics for recursion at the level of types. Care must be taken to ensure that a type name is not defined more than once, and that cycles do not arise among ‘transparent’ type definitions. In contrast to the usual continuation-passing interpretation of existential types in terms of universal types, our account of type generativity suggests a destination-passing interpretation. Briefly, instead of viewing a value of existential type as something that creates a new abstract type every time it is unpacked, we view it as a function that takes as input a pre-existing undefined abstract type and defines it. By leaving the creation of the abstract type name up to the client of the existential, our approach makes it significantly easier to link abstract data types together recursively.

Type
Article
Copyright
Copyright © Cambridge University Press 2007

References

Amadio, R. & Cardelli, L. (1993) Subtyping recursive types. ACM Trans. Program. Lang. Syst. 15 (4), 575631.CrossRefGoogle Scholar
Ancona, D. & Zucca, E. (1999) A primitive calculus for module systems. In International Conference on Principles and Practice of Declarative Programming (PPDP). Lecture Notes in Computer Science, vol. 1702. London, UK: Springer-Verlag, pp. 6279.CrossRefGoogle Scholar
Benton, N. & Leperchey, B. (2005) Relational reasoning in a nominal semantics for storage. In International Conference on Typed Lambda Calculi and Applications (TLCA), pp. 86–101.CrossRefGoogle Scholar
Bohr, N. & Birkedal, L. (2006) Relational reasoning for recursive types and references. In Asian Symposium on Programming Languages and Systems (APLAS), pp. 79–96.CrossRefGoogle Scholar
Crary, K., Harper, R. & Puri, S. (1999) What is a recursive module? In ACM Conference on Programming Language Design and Implementation (PLDI), pp. 50–63.Google Scholar
Dreyer, D. (2004) A type system for well-founded recursion. In ACM Symposium on Principles of Programming Languages (POPL), pp. 293–305.CrossRefGoogle Scholar
Dreyer, D. (2005a) Recursive type generativity. In International Conference on Functional Programming (ICFP), pp. 41–53.CrossRefGoogle Scholar
Dreyer, D. (2005b) Understanding and Evolving the ML Module System, Ph.D. thesis. Pittsburgh, PA: Carnegie Mellon University.Google Scholar
Dreyer, D. (2006) Practical Type Theory for Recursive Modules, Tech. rept. TR-2006-07. Department of Computer Science, University of Chicago.Google Scholar
Dreyer, D. & Blume, M. (2007) Principal type schemes for modular programs. In European Symposium on Programming (ESOP). pp. 441–457.CrossRefGoogle Scholar
Dreyer, D., Crary, K. & Harper, R. (2003) A type system for higher-order modules. In ACM Symposium on Principles of Programming Languages (POPL). pp. 236–249.CrossRefGoogle Scholar
Duggan, D. (2002) Type-safe linking with recursive DLL's and shared libraries. ACM Trans. Program. Lang. Syst., 24 (6), 711804.CrossRefGoogle Scholar
Flatt, M. (2005) PLT MzScheme: Language Manual. Available at:www.plt-scheme.org.Google Scholar
Flatt, M. & Felleisen, M. (1998) Units: Cool modules for HOT languages. In ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), pp. 236–248.CrossRefGoogle Scholar
Gifford, D. K. & Lucassen, J. M. (1986) Integrating functional and imperative programming. ACM Conference on LISP and Functional Programming. pp. 28–38.CrossRefGoogle Scholar
Harper, R. & Stone, C. (2000) A type-theoretic interpretation of Standard ML. In Plotkin, G., Stirling, C.Tofte, M. (eds) Proof, Language, and Interaction: Essays in Honor of Robin Milner. Cambridge, MA: MIT Press. pp. 341387.CrossRefGoogle Scholar
Jones, M. P. (1996) Using parameterized signatures to express modular structure. In ACM Symposium on Principles of Programming Languages (POPL), pp. 68–78.CrossRefGoogle Scholar
Koutavas, V. & Wand, M. (2006) Small bisimulations for reasoning about higher-order imperative programs. ACM SIGPLAN Symposium on Principles of Programming Languages (POPL), pp. 141–152.CrossRefGoogle Scholar
Leroy, X. (1995) Applicative functors and fully transparent higher-order modules. ACM SIGPLAN Symposium on Principles of Programming Languages (POPL) pp. 142–153.CrossRefGoogle Scholar
Leroy, X. (2003) A Proposal for Recursive Modules in Objective Caml. Available from the author's website.Google Scholar
Leroy, X. (2004) The Objective Caml System: Documentation and User's Manual. Available at: www.ocaml.org.Google Scholar
Milner, R., Tofte, M., Harper, R. & MacQueen, D. (1997) The Definition of Standard ML (Revised). Cambridge, MA: MIT Press.CrossRefGoogle Scholar
Mitchell, J. C. (1996) Foundations for Programming Languages. Cambridge, MA: MIT Press.Google Scholar
Morrisett, G., Ahmed, A. & Fluet, M. (2005) L3: A linear language with locations. In International Conference on Typed Lambda Calculi and Applications (TLCA), pp. 293–307.CrossRefGoogle Scholar
Okasaki, C. (1998) Purely Functional Data Structures. Cambridge, UK: Cambridge University Press.CrossRefGoogle Scholar
Pitts, A. (2005) Typed operational reasoning. In Advanced Topics in Types and Programming Languages, Pierce, B. C. (ed). Cambridge, MA: MIT Press, chap. 7.Google Scholar
Romanenko, S., Russo, C. & Sestoft, P. (2000) Moscow ML Language Overview. Available at: www.dina.kvl.dk/sestoft/mosml.html.Google Scholar
Rossberg, A. (2003) Generativity and dynamic opacity for abstract types. In International Conference on Principles and Practice of Declarative Programming (PPDP). pp. 241–252.CrossRefGoogle Scholar
Russo, C. V. (2001) Recursive structures for Standard ML. In International Conference on Functional Programming (ICFP), pp. 50–61.CrossRefGoogle Scholar
Stone, C. A. (2005) Type definitions. In Advanced Topics in Types and Programming Languages Pierce, B. C. (ed). Cambridge, MA: MIT Press, chap. 9.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. (1994) The type and effect discipline. Inf. Comput. 111 (2), 245296.CrossRefGoogle Scholar
Vanderwaart, J. C., Dreyer, D., Petersen, L., Crary, K., Harper, R. & Cheng, P. (2003) Typed compilation of recursive datatypes. In ACM SIGPLAN Workshop on Types in Language Design and Implementation (TLDI). pp. 98–108.CrossRefGoogle Scholar
Wadler, P. (1985) Listlessness is Better than Laziness, Ph.D. thesis. Pittsburgh, PA: Carnegie Mellon University.CrossRefGoogle Scholar
Wadler, P. (1990) Linear types can change the world! In IFIP TC 2 Working Conference on Programming Concepts and Methods. pp. 347–359.Google Scholar
Walker, D., Crary, K. & Morrisett, G. (2000) Typed memory management via static capabilities. ACM Trans. Program. Lang. Syst. 22 (4), 701771.CrossRefGoogle Scholar
Submit a response

Discussions

No Discussions have been published for this article.