Skip to main content
×
×
Home

Recursive type generativity

  • DEREK DREYER (a1)
Abstract
Abstract

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.

Copyright
References
Hide All
Amadio R. & Cardelli L. (1993) Subtyping recursive types. ACM Trans. Program. Lang. Syst. 15 (4), 575631.
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.
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.
Bohr N. & Birkedal L. (2006) Relational reasoning for recursive types and references. In Asian Symposium on Programming Languages and Systems (APLAS), pp. 79–96.
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.
Dreyer D. (2004) A type system for well-founded recursion. In ACM Symposium on Principles of Programming Languages (POPL), pp. 293–305.
Dreyer D. (2005a) Recursive type generativity. In International Conference on Functional Programming (ICFP), pp. 41–53.
Dreyer D. (2005b) Understanding and Evolving the ML Module System, Ph.D. thesis. Pittsburgh, PA: Carnegie Mellon University.
Dreyer D. (2006) Practical Type Theory for Recursive Modules, Tech. rept. TR-2006-07. Department of Computer Science, University of Chicago.
Dreyer D. & Blume M. (2007) Principal type schemes for modular programs. In European Symposium on Programming (ESOP). pp. 441–457.
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.
Duggan D. (2002) Type-safe linking with recursive DLL's and shared libraries. ACM Trans. Program. Lang. Syst., 24 (6), 711804.
Flatt M. (2005) PLT MzScheme: Language Manual. Available at:www.plt-scheme.org.
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.
Gifford D. K. & Lucassen J. M. (1986) Integrating functional and imperative programming. ACM Conference on LISP and Functional Programming. pp. 28–38.
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.
Jones M. P. (1996) Using parameterized signatures to express modular structure. In ACM Symposium on Principles of Programming Languages (POPL), pp. 68–78.
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.
Leroy X. (1995) Applicative functors and fully transparent higher-order modules. ACM SIGPLAN Symposium on Principles of Programming Languages (POPL) pp. 142–153.
Leroy X. (2003) A Proposal for Recursive Modules in Objective Caml. Available from the author's website.
Leroy X. (2004) The Objective Caml System: Documentation and User's Manual. Available at: www.ocaml.org.
Milner R., Tofte M., Harper R. & MacQueen D. (1997) The Definition of Standard ML (Revised). Cambridge, MA: MIT Press.
Mitchell J. C. (1996) Foundations for Programming Languages. Cambridge, MA: MIT Press.
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.
Okasaki C. (1998) Purely Functional Data Structures. Cambridge, UK: Cambridge University Press.
Pitts A. (2005) Typed operational reasoning. In Advanced Topics in Types and Programming Languages, Pierce B. C. (ed). Cambridge, MA: MIT Press, chap. 7.
Romanenko S., Russo C. & Sestoft P. (2000) Moscow ML Language Overview. Available at: www.dina.kvl.dk/sestoft/mosml.html.
Rossberg A. (2003) Generativity and dynamic opacity for abstract types. In International Conference on Principles and Practice of Declarative Programming (PPDP). pp. 241–252.
Russo C. V. (2001) Recursive structures for Standard ML. In International Conference on Functional Programming (ICFP), pp. 50–61.
Stone C. A. (2005) Type definitions. In Advanced Topics in Types and Programming Languages Pierce B. C. (ed). Cambridge, MA: MIT Press, chap. 9.
Stone C. A. & Harper R. (2006) Extensional equivalence and singleton types. ACM Trans. Comput. Logic., 7 (4), 676722.
Talpin J.-P. & Jouvelot P. (1994) The type and effect discipline. Inf. Comput. 111 (2), 245296.
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.
Wadler P. (1985) Listlessness is Better than Laziness, Ph.D. thesis. Pittsburgh, PA: Carnegie Mellon University.
Wadler P. (1990) Linear types can change the world! In IFIP TC 2 Working Conference on Programming Concepts and Methods. pp. 347–359.
Walker D., Crary K. & Morrisett G. (2000) Typed memory management via static capabilities. ACM Trans. Program. Lang. Syst. 22 (4), 701771.
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: 0
Total number of PDF views: 7 *
Loading metrics...

Abstract views

Total abstract views: 80 *
Loading metrics...

* Views captured on Cambridge Core between September 2016 - 17th January 2018. This data will be updated every 24 hours.