A type system for well-founded recursion

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.

[1]  Matthias Felleisen,et al.  Units: cool modules for HOT languages , 1998, PLDI.

[2]  John Launchbury,et al.  A recursive do for Haskell , 2002, Haskell '02.

[3]  M. Tofte Operational Semantics and Polymorphic Type Inference , 1988 .

[4]  R. Harper,et al.  Toward a Practical Type Theory for Recursive Modules , 2001 .

[5]  Dominic Duggan,et al.  Mixin modules , 1996, ICFP '96.

[6]  Andrew M. Pitts,et al.  A Metalanguage for Programming with Bound Names Modulo Renaming , 2000, MPC.

[7]  Chris Hankin,et al.  Abstract Interpretation of Declarative Languages , 1987 .

[8]  John Greiner,et al.  Weak polymorphism can be sound , 1996, Journal of Functional Programming.

[9]  Chris Okasaki,et al.  Purely functional data structures , 1998 .

[10]  Karl Crary,et al.  What is a recursive module? , 1999, PLDI '99.

[11]  Aleksandar Nanevski A modal calculus for effect handling , 2003 .

[12]  Gérard Boudol The Recursive Record Semantics of Objects Revisited , 2001, ESOP.

[13]  Karl Crary,et al.  A type system for higher-order modules , 2003, POPL '03.

[14]  John Launchbury,et al.  Recursive monadic bindings , 2000, ICFP '00.

[15]  Derek Dreyer,et al.  A type system for higher-order modules , 2003, POPL '03.

[16]  Mark Lillibridge,et al.  A type-theoretic approach to higher-order modules with sharing , 1994, POPL '94.

[17]  Jonathan Rees,et al.  Revised3 report on the algorithmic language scheme , 1986, SIGP.

[18]  David B. MacQueen,et al.  The Definition of Standard ML (Revised) , 1997 .

[19]  Amr Sabry,et al.  An Abstract Monadic Semantics for Value Recursion , 2004, FICS.

[20]  DreyerDerek A type system for well-founded recursion , 2004 .

[21]  Andrew K. Wright Simple imperative polymorphism , 1995, LISP Symb. Comput..

[22]  Levent Erkok,et al.  A Recursive do for Haskell: Design And Implementation , 2000 .

[23]  Tom Hirschowitz,et al.  Compilation of extended recursion in call-by-value functional languages , 2003, PPDP '03.

[24]  Davide Ancona,et al.  Mixin Modules and Computational Effects , 2003, ICALP.

[25]  Aleksandar Nanevski Meta-programming with names and necessity , 2002, ICFP '02.

[26]  Xavier Leroy A proposal for recursive modules in Objective Caml , 2003 .

[27]  Robert Hieb,et al.  Revised 5 Report on the Algorithmic Language , 1999 .

[28]  Tom Hirschowitz,et al.  Mixin modules in a call-by-value setting , 2002, TOPL.

[29]  R. Kent Dybvig,et al.  Revised5 Report on the Algorithmic Language Scheme , 1986, SIGP.

[30]  Claudio V. Russo Recursive Structures for Standard ML , 2001, ICFP.

[31]  Pierre Jouvelot,et al.  The type and effect discipline , 1992, [1992] Proceedings of the Seventh Annual IEEE Symposium on Logic in Computer Science.

[32]  Robin Milner,et al.  Definition of standard ML , 1990 .

[33]  Davide Ancona,et al.  A Primitive Calculus for Module Systems , 1999, PPDP.