Side-effect localization for lazy, purely functional languages via aspects

Many side-effecting programming activities, such as profiling and tracing, can be formulated as crosscutting concerns and be framed as side-effecting aspects in the aspect-oriented programming paradigm. The benefit gained from this separation of concerns is particularly evident in purely functional programming, as adding such aspects using techniques such as monadification will generally lead to crosscutting changes. This paper presents an approach to provide side-effecting aspects for lazy purely functional languages in a user transparent fashion. We propose a simple yet direct state manipulation construct for developing side-effecting aspects and devise a systematic monadification scheme to translate the woven code to monadic style purely functional code. Furthermore, we present a static and dynamic semantics of the aspect programs and reason about the correctness of our monadification scheme with respect to them.

[1]  Olivier Danvy,et al.  A generic account of continuation-passing styles , 1994, POPL '94.

[2]  Wolfgang De Meuter Monads as a theoretical foundation for AOP , 2000 .

[3]  Martin Erwig,et al.  Monadification of functional programs , 2004, Sci. Comput. Program..

[4]  William G. Griswold,et al.  An Overview of AspectJ , 2001, ECOOP.

[5]  Paul Hudak,et al.  Semantics directed program execution monitoring , 1995, Journal of Functional Programming.

[6]  Sebastian Fischer,et al.  Purely functional lazy non-deterministic programming , 2009, Journal of Functional Programming.

[7]  Simon L. Peyton Jones,et al.  HsDebug: debugging lazy programs by not being lazy , 2003, Haskell '03.

[8]  David Walker,et al.  AspectML: A polymorphic aspect-oriented functional programming language , 2008, TOPL.

[9]  Christian Hofer,et al.  On the relation of aspects and monads , 2007, FOAL.

[10]  David Walker,et al.  Harmless advice , 2006, POPL '06.

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

[12]  Simon L. Peyton Jones,et al.  Imperative functional programming , 1993, POPL '93.

[13]  Sebastian Fischer,et al.  Purely functional lazy nondeterministic programming , 2011, J. Funct. Program..

[14]  Amir Shai Kishon Theory and art of semantics-directed program execution monitoring , 1992 .

[15]  Ralf Lämmel Reuse by Program Transformation , 1999, Scottish Functional Programming Workshop.

[16]  John Launchbury,et al.  A natural semantics for lazy evaluation , 1993, POPL '93.

[17]  Amr Sabry,et al.  The essence of compiling with continuations , 1993, PLDI '93.

[18]  Meng Wang,et al.  Type-directed weaving of aspects for higher-order functional languages , 2006, PEPM '06.

[19]  Amey Karkare,et al.  Heap reference analysis using access graphs , 2006, ACM Trans. Program. Lang. Syst..

[20]  Meng Wang,et al.  What does aspect-oriented programming mean for functional programmers? , 2009, WGP '09.

[21]  Sibylle Schupp,et al.  Proceedings of the 2009 ACM SIGPLAN workshop on Generic programming, WGP@ICFP 2009, Edinburgh, United Kingdom, August 31 - September 2, 2009 , 2009, WGP@ICFP.

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

[23]  Akinori Yonezawa,et al.  Aspectual Caml: an aspect-oriented functional language , 2005, ICFP '05.

[24]  Meng Wang,et al.  A Compilation Model for Aspect-Oriented Polymorphically Typed Functional Languages , 2007, SAS.

[25]  Simon L. Peyton Jones,et al.  Once upon a polymorphic type , 1999, POPL '99.