Abstraction and Performance from Explicit Monadic Reflectio n

Most of the existing literature about monadic programming focuses on theory but does not address issues of software engineering. Using monadic parsing as a running example, we demonstrate monadic programs written in a typical style, recognize how they violate abstraction boundaries, and recover clean abstraction crossings through monadic reflection. Once monadic reflection is made explicit, it is possible to construct a grammar for monadic programming that is independent of domain-specific operations. This grammar, in turn, enables the redefinition of the monadic operators as macros that eliminate at expansion time the overhead imposed by functional representations. The results are very efficient monadic programs; for parsing, the output code is competitive with good hand-crafted parsers.

[1]  Richard S. Bird,et al.  Introduction to functional programming using haskeu , 1998 .

[2]  Graham Hutton,et al.  Higher-order functions for parsing , 1992, Journal of Functional Programming.

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

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

[5]  David A. Schmidt Detecting global variables in denotational specifications , 1985, TOPL.

[6]  D. H. Bartley,et al.  Revised4 report on the algorithmic language scheme , 1991, LIPO.

[7]  Peter Thiemann,et al.  The essence of LR parsing , 1995, PEPM '95.

[8]  R. Kent Dybvig,et al.  Revised5 Report on the Algorithmic Language Scheme , 1986, SIGP.

[9]  B. J. Mailloux,et al.  Report on the Algorithmic Language , 1971 .

[10]  E. Meijer,et al.  Monadic parser combinators , 1996 .

[11]  Paul Hudak,et al.  Rolling your own mutable ADT—a connection between linear types and monads , 1997, POPL '97.

[12]  Graham Hutton,et al.  Monadic parsing in Haskell , 1998, Journal of Functional Programming.

[13]  Richard S. Bird,et al.  Introduction to functional programming , 1988, Prentice Hall International series in computer science.

[14]  Jonathan Rees,et al.  Revised3 report on the algorithmic language scheme , 1986, SIGP.

[15]  Robert Hieb,et al.  A new approach to procedures with variable arity , 1990, LISP Symb. Comput..

[16]  H. Kleisli,et al.  Every standard construction is induced by a pair of adjoint functors , 1965 .

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

[18]  Philip Wadler,et al.  Packrat parsing:: simple, powerful, lazy, linear time, functional pearl , 2002, ICFP '02.

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