Convenient Explicit Effects using Type Inference with Subeffects

Most programming languages in use today let one freely use arbitrary (side) effects. This is despite the fact that unknown and unrestricted side effects are the cause of many software problems. We propose a programming model where effects are treated in a disciplined way, and where the potential side-effects of a function are apparent in its type signature. In contrast to most effect systems that are meant for internal compiler optimizations, our system is designed to be used by the programmer. Inspired by Haskell, we use a coarse-grained hierarchy of effects, like pure and io, which makes it convenient to read and write type signatures. The type and effect of expressions can also be inferred automatically, and we describe a polymorphic type inference system based on Hindley-Milner style inference.

[1]  Flemming Nielson,et al.  Polymorphic Subtyping for Effect Analysis: The Static Semantics , 1996, LOMAPS.

[2]  Nick Benton,et al.  Semantics of an effect analysis for exceptions , 2007, TLDI '07.

[3]  Mark P. Jones A Theory of Qualified Types , 1992, ESOP.

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

[5]  Philip Wadler,et al.  Combining Monads , 1992 .

[6]  John Launchbury,et al.  Structuring depth-first search algorithms in Haskell , 1995, POPL '95.

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

[8]  Geoffrey Smith Polymorphic Type Inference for Languages with Overloading and Subtyping , 1991 .

[9]  John C. Reynolds,et al.  Using category theory to design implicit conversions and generic operators , 1980, Semantics-Directed Compiler Generation.

[10]  R. Hindley The Principal Type-Scheme of an Object in Combinatory Logic , 1969 .

[11]  Xavier Leroy,et al.  Polymorphism by name for references and continuations , 1993, POPL '93.

[12]  Andrew P. Tolmach,et al.  Optimizing ML Using a Hierarchy of Monadic Types , 1998, Types in Compilation.

[13]  David A. Naumann,et al.  Observational purity and encapsulation , 2005, Theor. Comput. Sci..

[14]  Paul Hudak,et al.  Monad transformers and modular interpreters , 1995, POPL '95.

[15]  Robin Milner,et al.  A Theory of Type Polymorphism in Programming , 1978, J. Comput. Syst. Sci..

[16]  Mark P. Jones,et al.  From Hindley-Milner Types to First-Class Structures , 2001 .

[17]  François Pessaux,et al.  Type-based analysis of uncaught exceptions , 2000, TOPL.

[18]  François Pottier,et al.  Simplifying subtyping constraints , 1996, ICFP '96.

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

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

[21]  Daniel Marino,et al.  A generic type-and-effect system , 2009, TLDI '09.

[22]  Martin Hofmann,et al.  Relational semantics for effect-based program transformations with dynamic allocation , 2007, PPDP '07.

[23]  Lars Birkedal,et al.  A region inference algorithm , 1998, TOPL.

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

[25]  John C. Mitchell,et al.  Type inference with simple subtypes , 1991, Journal of Functional Programming.

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

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