Monads, zippers and views: virtualizing the monad stack

We make monadic components more reusable and robust to changes by employing two new techniques for virtualizing the monad stack: the monad zipper and monad views. The monad zipper is a higher-order monad transformer that creates virtual monad stacks by ignoring particular layers in a concrete stack. Monad views provide a general framework for monad stack virtualization: they take the monad zipper one step further and integrate it with a wide range of other virtualizations. For instance, particular views allow restricted access to monads in the stack. Furthermore, monad views provide components with a call-by-reference-like mechanism for accessing particular layers of the monad stack. With our two new mechanisms, the monadic effects required by components no longer need to be literally reflected in the concrete monad stack. This makes these components more reusable and robust to changes.

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

[2]  Gérard P. Huet,et al.  The Zipper , 1997, Journal of Functional Programming.

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

[4]  Philip Wadler,et al.  How to make ad-hoc polymorphism less ad hoc , 1989, POPL '89.

[5]  Philip Wadler,et al.  Theorems for free! , 1989, FPCA.

[6]  William R. Cook,et al.  Monadic Memoization Mixins , 2006 .

[7]  Bruno C. d. S. Oliveira,et al.  EffectiveAdvice: disciplined advice with explicit effects , 2010, AOSD.

[8]  Mauro Jaskelioff Monatron: An Extensible Monad Transformer Library , 2008, IFL.

[9]  Perry Alexander,et al.  Monad Factory: Type-Indexed Monads , 2010, Trends in Functional Programming.

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

[11]  Ralf Lämmel,et al.  Strongly typed heterogeneous collections , 2004, Haskell '04.

[12]  Andrzej Filinski Monads in action , 2010, POPL '10.

[13]  Pietro Cenciarelli,et al.  A Syntactic Approach to Modularity in Denotational Semantics , 1993 .

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

[15]  Peter J. Stuckey,et al.  Search combinators , 2012, Constraints.

[16]  Joyce L. Vedral,et al.  Functional Programming Languages and Computer Architecture , 1989, Lecture Notes in Computer Science.

[17]  Wouter Swierstra,et al.  Data types à la carte , 2008, Journal of Functional Programming.

[18]  John C. Reynolds,et al.  Types, Abstraction and Parametric Polymorphism , 1983, IFIP Congress.

[19]  Bruno C. d. S. Oliveira,et al.  The monad zipper , 2010 .

[20]  Martin Odersky,et al.  Type classes as objects and implicits , 2010, OOPSLA.

[21]  Philip Wadler,et al.  Views: a way for pattern matching to cohabit with data abstraction , 1987, POPL '87.

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

[23]  Peter J. Stuckey,et al.  CP and IP approaches to cancer radiotherapy delivery optimization , 2011, Constraints.

[24]  Guy L. Steele,et al.  Building interpreters by composing monads , 1994, POPL '94.

[25]  William R. Cook,et al.  A denotational semantics of inheritance , 1989 .

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

[27]  Peyton Jones,et al.  Haskell 98 language and libraries : the revised report , 2003 .