A Modal Calculus for Exception Handling

The exception monad, while an adequate mechanism for providing the denotational semantics of exceptions, is somewhat awkward to program with. Just as any other monad, it forces a programming style in which exceptional computations are explicitly sequentialized in the program text. In addition, values of computation types must usually be tested before use, in order to determine if they correspond to a raised exception. In this paper we propose a type system that rearranges the monadic formulation, so that the above shortcomings are avoided. Instead of the exception monad, we propose the operator from the modal logic S4 to encode exceptional computation. The way tracking of exceptions is organized in the modal system is exactly dual to the monadic case, reecting the well-known property that is actually a comonad.

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

[2]  Frank Pfenning,et al.  A judgmental reconstruction of modal logic , 2001, Mathematical Structures in Computer Science.

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

[4]  David K. Gifford,et al.  Integrating functional and imperative programming , 1986, LFP '86.

[5]  S. Brookes,et al.  Applications of Categories in Computer Science: Computational comonads and intensional semantics , 1992 .

[6]  Frank Pfenning,et al.  Functional programming with names and necessity , 2004 .

[7]  Richard Kieburtz Codata and Comonads in Haskell , 1999 .

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

[9]  Simon L. Peyton Jones,et al.  A semantics for imprecise exceptions , 1999, PLDI '99.

[10]  Peter Lee,et al.  Modal types as staging specifications for run-time code generation , 1998, CSUR.

[11]  Satoshi Kobayashi,et al.  Monad as Modality , 1997, Theor. Comput. Sci..

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

[13]  Andrzej Filinski,et al.  Representing monads , 1994, POPL '94.

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

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

[16]  Andrzej Filinski,et al.  Representing layered monads , 1999, POPL '99.

[17]  Philip Wadler Monads for Functional Programming , 1995, Advanced Functional Programming.

[18]  Philippe de Groote,et al.  A Simple Calculus of Exception Handling , 1995, TLCA.

[19]  Hiroshi Nakano A constructive formalization of the catch and throw mechanism , 1992, [1992] Proceedings of the Seventh Annual IEEE Symposium on Logic in Computer Science.

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

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

[22]  Nick Benton,et al.  Computational types from a logical perspective , 1998, Journal of Functional Programming.

[23]  Michael Mendler,et al.  Propositional Lax Logic , 1997, Inf. Comput..

[24]  Natasha Alechina,et al.  Categorical and Kripke Semantics for Constructive Modal Logics , 2001 .

[25]  Andrew M. Pitts,et al.  A First Order Theory of Names and Binding , 2001 .

[26]  Pierre Jouvelot,et al.  Reasoning about continuations with control effects , 1989, PLDI '89.

[27]  Yukiyoshi Kameyama,et al.  Strong normalizability of the non-deterministic catch/throw calculi , 2002, Theor. Comput. Sci..

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

[29]  Peter Lee,et al.  Run-time code generation and modal-ML , 1998, PLDI.

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

[31]  Guy L. Steele,et al.  The Java Language Specification , 1996 .

[32]  Valeria de Paiva,et al.  On an Intuitionistic Modal Logic , 2000, Stud Logica.

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

[34]  Pierre Jouvelot,et al.  Algebraic reconstruction of types and effects , 1991, POPL '91.

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