Monads in action

In functional programming, monadic characterizations of computational effects are normally understood denotationally: they describe how an effectful program can be systematically expanded or translated into a larger, pure program, which can then be evaluated according to an effect-free semantics. Any effect-specific operations expressible in the monad are also given purely functional definitions, but these definitions are only directly executable in the context of an already translated program. This approach thus takes an inherently Church-style view of effects: the nominal meaning of every effectful term in the program depends crucially on its type. We present here a complementary, operational view of monadic effects, in which an effect definition directly induces an imperative behavior of the new operations expressible in the monad. This behavior is formalized as additional operational rules for only the new constructs; it does not require any structural changes to the evaluation judgment. Specifically, we give a small-step operational semantics of a prototypical functional language supporting programmer-definable, layered effects, and show how this semantics naturally supports reasoning by familiar syntactic techniques, such as showing soundness of a Curry-style effect-type system by the progress+preservation method.

[1]  Peter D. Mosses,et al.  Modular structural operational semantics , 2004, J. Log. Algebraic Methods Program..

[2]  Matthias Felleisen,et al.  The Denotational Specifications of Complex Languages , 2005 .

[3]  Andrzej Filinski On the relations between monadic semantics , 2007, Theor. Comput. Sci..

[4]  Paul Blain Levy,et al.  Call-by-push-value: Decomposing call-by-value and call-by-name , 2006, High. Order Symb. Comput..

[5]  Karl Crary,et al.  Syntactic Logical Relations for Polymorphic and Recursive Types , 2007, Computation, Meaning, and Logic.

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

[7]  Gordon D. Plotkin,et al.  Algebraic Operations and Generic Effects , 2003, Appl. Categorical Struct..

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

[9]  Gordon D. Plotkin,et al.  An axiomatisation of computationally adequate domain theoretic models of FPC , 1994, Proceedings Ninth Annual IEEE Symposium on Logic in Computer Science.

[10]  Andrzej Filinski,et al.  Inductive reasoning about effectful data types , 2007, ICFP '07.

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

[12]  Robert Hieb,et al.  The Revised Report on the Syntactic Theories of Sequential Control and State , 1992, Theor. Comput. Sci..

[13]  Didier Rémy,et al.  A generalization of exceptions and control in ML-like languages , 1995, FPCA '95.

[14]  Benjamin C. Pierce,et al.  Types and programming languages: the next generation , 2003, 18th Annual IEEE Symposium of Logic in Computer Science, 2003. Proceedings..

[15]  Frank Pfenning Substructural Operational Semantics , 2006 .

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

[17]  S. Lane Categories for the Working Mathematician , 1971 .

[18]  Frank Pfenning Substructural Operational Semantics and Linear Destination-Passing Style (Invited Talk) , 2004, APLAS.

[19]  Amr Sabry,et al.  Delimited dynamic binding , 2006, ICFP '06.

[20]  Luc Moreau,et al.  A Syntactic Theory of Dynamic Binding , 1997, High. Order Symb. Comput..

[21]  Frank Pfenning,et al.  System Description: Twelf - A Meta-Logical Framework for Deductive Systems , 1999, CADE.

[22]  Gordon D. Plotkin,et al.  Handlers of Algebraic Effects , 2009, ESOP.