Nothing Special   »   [go: up one dir, main page]

skip to main content
10.1145/964001.964026acmconferencesArticle/Chapter ViewAbstractPublication PagespoplConference Proceedingsconference-collections
Article

A type system for well-founded recursion

Published: 01 January 2004 Publication History

Abstract

In the interest of designing a recursive module extension to ML that is as simple and general as possible, we propose a novel type system for general recursion over effectful expressions. The presence of effects seems to necessitate a backpatching semantics for recursion similar to that of Scheme. Our type system ensures statically that recursion is well-founded---that the body of a recursive expression will evaluate without attempting to access the undefined recursive variable---which avoids some unnecessary run-time costs associated with backpatching. To ensure well-founded recursion in the presence of multiple recursive variables and separate compilation, we track the usage of individual recursive variables, represented statically by "names". So that our type system may eventually be integrated smoothly into ML's, reasoning involving names is only required inside code that uses our recursive construct and need not infect existing ML code, although instrumentation of some existing code can help to improve the precision of our type system.

References

[1]
Samson Abramsky and Chris Hankin, editors. Abstract Interpretation of Declarative Languages. Ellis Horwood Limited, 1987.
[2]
Davide Ancona, Sonia Fagorzi, Eugenio Moggi, and Elena Zucca. Mixin modules and computational effects. In 2003 International Colloquium on Languages, Automata and Programming, Eindhoven, The Netherlands, 2003.
[3]
Davide Ancona and Elena Zucca. A primitive calculus for module systems. In International Conference on Principles and Practice of Declarative Programming, volume 1702 of Lecture Notes in Computer Science, pages 62--79. Springer-Verlag, 1999.
[4]
Gerard Boudol. The recursive record semantics of objects revisited. Research report 4199, INRIA, 2001. To appear in the Journal of Functional Programming.
[5]
Karl Crary, Robert Harper, and Sidd Puri. What is a recursive module? In 1999 Conference on Programming Language Design and Implementation (PLDI), pages 50--63, Atlanta, GA.
[6]
Derek Dreyer, Karl Crary, and Robert Harper. A type system for higher-order modules. In 2003 ACM Symposium on Principles of Programming Languages, pages 236--249, 2003.
[7]
Derek Dreyer, Robert Harper, and Karl Crary. A type system for well-founded recursion. Technical Report CMU-CS-03-163, Carnegie Mellon University, July 2003.
[8]
Derek R. Dreyer, Robert Harper, and Karl Crary. Toward a practical type theory for recursive modules. Technical Report CMU-CS-01-112, School of Computer Science, Carnegie Mellon University, March 2001.
[9]
Dominic Duggan and Constantinos Sourelis. Mixin modules. In 1996 ACM SIGPLAN International Conference on Functional Programming, pages 262--273, Philadelphia, Pennsylvania, June 1996.
[10]
Dominic Duggan and Constantinos Sourelis. Parameterized modules, recursive modules, and mixin modules. In 1998 ACM SIGPLAN Workshop on ML, pages 87--96, Baltimore, Maryland, September 1998.
[11]
Levent Erkök and John Launchbury. Recursive monadic bindings. In 2000 International Conference on Functional Programming, pages 174--185, Paris, France, 2000.
[12]
Levent Erkök and John Launchbury. A recursive do for Haskell. In 2002 Haskell Workshop, October 2002.
[13]
Matthew Flatt and Matthias Felleisen. Units: Cool modules for HOT languages. In 1998 ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 236--248, Montreal, Canada, June 1998.
[14]
Daniel P. Friedman and Amr Sabry. Recursion is a computational effect. Technical Report TR546, Indiana University, December 2000.
[15]
John Greiner. Weak polymorphism can be sound. Journal of Functional Programming, 6(1):111--141, 1996.
[16]
Robert Harper and Mark Lillibridge. A type-theoretic approach to higher-order modules with sharing. In Twenty-First ACM Symposium on Principles of Programming Languages, pages 123--137, Portland, OR, January 1994.
[17]
Tom Hirschowitz and Xavier Leroy. Mixin modules in a call-by-value setting. In 2002 European Symposium on Programming, volume 2305 of Lecture Notes in Computer Science, pages 6--20, 2002.
[18]
Tom Hirschowitz, Xavier Leroy, and J. B. Wells. Compilation of extended recursion in call-by-value functional languages. In 2003 International Conference on Principles and Practice of Declarative Programming, Uppsala, Sweden.
[19]
Richard Kelsey, William Clinger, and Jonathan Rees (eds.). Revised5 report on the algorithmic language Scheme. Higher-Order and Symbolic Computation, 11(1), September 1998.
[20]
Xavier Leroy. A proposal for recursive modules in Objective Caml, May 2003. Available from the author's web site.
[21]
Robin Milner, Mads Tofte, Robert Harper, and David MacQueen. The Definition of Standard ML (Revised). MIT Press, 1997.
[22]
Eugenio Moggi and Amr Sabry. An abstract monadic semantics for value recursion. In 2003 Workshop on Fixed Points in Computer Science, April 2003.
[23]
Aleksandar Nanevski. Meta-programming with names and necessity. In 2002 International Conference on Functional Programming, pages 206--217, Pittsburgh, PA, 2002. A significant revision is available as a technical report CMU-CS-02-123R, Carnegie Mellon University.
[24]
Aleksandar Nanevski. A modal calculus for effect handling. Technical Report CMU-CS-03-149, Carnegie Mellon University, June 2003.
[25]
Objective Caml. http://www.ocaml.org+.
[26]
Chris Okasaki. Purely Functional Data Structures. Cambridge University Press, 1998.
[27]
Andrew M. Pitts and Murdoch J. Gabbay. A metalanguage for programming with bound names modulo renaming. In Roland Backhouse and José Nuno Oliveira, editors, Mathematics of Program Construction, volume 1837 of Lecture Notes in Computer Science, pages 230--255. Springer, 2000.
[28]
Claudio V. Russo. Recursive structures for Standard ML. In International Conference on Functional Programming, pages 50--61, Florence, Italy, September 2001.
[29]
Jean-Pierre Talpin and Pierre Jouvelot. The type and effect discipline. Information and Computation, 111(2):245--296, 1994.
[30]
Mads Tofte. Operational Semantics and Polymorphic Type Inference. PhD thesis, University of Edinburgh, 1988.
[31]
Andrew K. Wright. Simple imperative polymorphism. Lisp and Symbolic Computation, 8(4):343--355, 1995.

Cited By

View all

Recommendations

Reviews

David R Naugler

ML's module system-consisting of structures, signatures, and functors-is strictly hierarchical, forcing mutually recursive types and functions to be defined in the same module. The author uses a type-theoretical approach to design a type system for general recursion over effectful expressions. The proposed type system is designed to be as simple and as general as possible, and to be the basis for a future recursive module extension to ML. The work is limited to the dynamic components of recursive modules, and statically insures that recursion for these is well founded, namely, that the body of a recursive expression will evaluate without trying to access the undefined recursive variable. The type system is presented in the context of the (pure) simply typed &lgr;-calculus. Dreyer indicates how the results in this paper relate to other work in the field, and indicates directions for future work. This is a well-written technical and theoretical paper, in an active research area. It illustrates nicely how type theory can inform design and implementation in programming languages. The paper is appropriate for those with a solid background in both a functional language of the ML family and in type theory.

Access critical reviews of Computing literature here

Become a reviewer for Computing Reviews.

Comments

Please enable JavaScript to view thecomments powered by Disqus.

Information & Contributors

Information

Published In

cover image ACM Conferences
POPL '04: Proceedings of the 31st ACM SIGPLAN-SIGACT symposium on Principles of programming languages
January 2004
364 pages
ISBN:158113729X
DOI:10.1145/964001
  • cover image ACM SIGPLAN Notices
    ACM SIGPLAN Notices  Volume 39, Issue 1
    POPL '04
    January 2004
    352 pages
    ISSN:0362-1340
    EISSN:1558-1160
    DOI:10.1145/982962
    Issue’s Table of Contents
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

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 01 January 2004

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. effect systems
  2. recursion
  3. recursive modules
  4. yype systems

Qualifiers

  • Article

Conference

POPL04

Acceptance Rates

POPL '04 Paper Acceptance Rate 29 of 176 submissions, 16%;
Overall Acceptance Rate 824 of 4,130 submissions, 20%

Upcoming Conference

POPL '25

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)7
  • Downloads (Last 6 weeks)0
Reflects downloads up to 24 Nov 2024

Other Metrics

Citations

Cited By

View all

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