Monadic encapsulation of effects: a revised approach (extended version)

Launchbury and Peyton Jones came up with an ingenious idea for embedding regions of imperative programming in a pure functional language like Haskell. The key idea was based on a simple modification of Hindley-Milner's type system. Our first contribution is to propose a more natural encapsulation construct exploiting higher-order kinds, which achieves the same encapsulation effect, but avoids the ad hoc type parameter of the original proposal. The second contribution is a type safety result for encapsulation of strict state using both the original encapsulation construct and the newly introduced one. We establish this result in a more expressive context than the original proposal, namely in the context of the higher-order lambda-calculus. The third contribution is a type safety result for encapsulation of lazy state in the higher-order lambda-calculus. This result resolves an outstanding open problem on which previous proof attempts failed. In all cases, we formalize the intended implementations as simple big-step operational semantics on untyped terms, which capture interesting implementation details not captured by the reduction semantics proposed previously.

[1]  Jr. Allen B. Tucker,et al.  The Computer Science and Engineering Handbook , 1997 .

[2]  Martin Odersky,et al.  A Type System for a Lambda Calculus with Assignments , 1994, TACS.

[3]  Pierre Jouvelot,et al.  The Type and Effect Discipline , 1994, Inf. Comput..

[4]  John C. Reynolds,et al.  Syntactic control of interference , 1978, POPL.

[5]  Philip Wadler,et al.  The marriage of effects and monads , 1998, ICFP '98.

[6]  P. Wadler The Marriage of Eeects and Monads , 1998 .

[7]  Mads Tofte,et al.  Region-based Memory Management , 1997, Inf. Comput..

[8]  David K. Gifford,et al.  Polymorphic effect systems , 1988, POPL '88.

[9]  Amr Sabry,et al.  Monadic state: axiomatization and type safety , 1997, ICFP '97.

[10]  Eugenio Moggi,et al.  Computational lambda-calculus and monads , 1989, [1989] Proceedings. Fourth Annual Symposium on Logic in Computer Science.

[11]  Eugenio Moggi,et al.  Notions of Computation and Monads , 1991, Inf. Comput..

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

[13]  Philip Wadler,et al.  The essence of functional programming (Invited talk) , 1997 .

[14]  Mark Lillibridge,et al.  Explicit polymorphism and CPS conversion , 1993, POPL '93.

[15]  Samson Abramsky,et al.  Handbook of logic in computer science. , 1992 .

[16]  Philip Wadler,et al.  The essence of functional programming , 1992, POPL '92.

[17]  J. H. Geuvers Logics and type systems , 1993 .

[18]  Jon G. Riecke Delimiting the scope of effects , 1993, FPCA '93.

[19]  Mads Tofte,et al.  Type Inference for Polymorphic References , 1990, Inf. Comput..

[20]  John C. Mitchell,et al.  Abstract types have existential type , 1988, TOPL.

[21]  Simon L. Peyton Jones,et al.  Lazy functional state threads , 1994, PLDI '94.

[22]  Matthias Felleisen,et al.  A Syntactic Approach to Type Soundness , 1994, Inf. Comput..

[23]  Vipin Swarup,et al.  Assignments for Applicative Languages , 1991, FPCA.

[24]  Paul Hudak,et al.  Call by name, assignment, and the lambda calculus , 1993, POPL '93.

[25]  Amr Sabry,et al.  Monadic encapsulation in ML , 1999, ICFP '99.

[26]  Eugenio Moggi,et al.  Monadic Encapsulation of Effects: a Revised Approach , 1999, Electron. Notes Theor. Comput. Sci..

[27]  Robert Harper,et al.  A Simplified Account of Polymorphic References , 1994, Inf. Process. Lett..

[28]  Simon L. Peyton Jones,et al.  State in Haskell , 1995, LISP Symb. Comput..

[29]  Ramesh Viswanathan,et al.  Isolating side effects in sequential languages , 1995, POPL '95.

[30]  John C. Reynolds,et al.  On Functors Expressible in the Polymorphic Typed Lambda Calculus , 1993, Inf. Comput..

[31]  R. Viswanathan,et al.  Isolating Side E ects in Sequential , 1995 .

[32]  John C. Mitchell,et al.  Abstract types have existential types , 1985, POPL.

[33]  Robert Harper,et al.  A Note on "A Simplified Account of Polymorphic References" , 1996, Inf. Process. Lett..

[34]  Philip Wadler,et al.  Comprehending monads , 1990, LISP and Functional Programming.

[35]  Pierre Jouvelot,et al.  Polymorphic type, region and effect inference , 1992, Journal of Functional Programming.

[36]  Paul Hudak,et al.  Calculi for functional programming languages with assignment , 1996 .