Higher-Order and Symbolic Computation

, Volume 24, Issue 1–2, pp 151–189 | Cite as

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

  • Kung ChenEmail author
  • Shu-Chun Weng
  • Jia-Yin Lin
  • Meng Wang
  • Siau-Cheng Khoo


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.


Aspect-oriented programming Side-effect Lazy semantics Monadification 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Chen, K., Weng, S.-C., Wang, M., Khoo, S.-C., Chen, C.-H.: A compilation model for aspect-oriented polymorphically typed functional languages. In: Static Analysis, 14th International Symposium, SAS 2007. LNCS, vol. 4634, pp. 34–51 (2007) CrossRefGoogle Scholar
  2. 2.
    Dantas, D.S., Walker, D.: Harmless advice. In: Proceedings of the 20th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 383–396 (2006) Google Scholar
  3. 3.
    Dantas, D.S., Walker, D., Washburn, G., Weirich, S.: AspectML: a polymorphic aspect-oriented functional programming language. ACM Trans. Program. Lang. Syst. 30(3), 1–60 (2008) CrossRefGoogle Scholar
  4. 4.
    Ennals, R., Jones, S.P.: HsDebug: debugging lazy programs by not being lazy. In: Haskell 03: Proceedings of the 2003 ACM SIGPLAN Workshop on Haskell, pp. 84–87 (2003) CrossRefGoogle Scholar
  5. 5.
    Erwig, M., Ren, D.: Monadification of functional programs. Sci. Comput. Program. 52(1–3), 101–129 (2004) MathSciNetzbMATHCrossRefGoogle Scholar
  6. 6.
    Fischer, S., Kiselyov, O., Shan, C.-C.: Purely functional lazy non-deterministic programming. In: ICFP ’09: Proceedings of the 10th ACM SIGPLAN International Conference on Functional Programming, New York, NY, USA, pp. 11–22 (2009) CrossRefGoogle Scholar
  7. 7.
    Flanagan, C., Sabry, A., Duba, B.F., Felleisen, M.: The essence of compiling with continuations. In: Proceedings of the ACM SIGPLAN 1993 Conference on Programming Language Design and Implementation, pp. 237–247 (1993) CrossRefGoogle Scholar
  8. 8.
    Functional Programming Group, K. U.: Monadification as a refactoring (2005) Google Scholar
  9. 9.
    Hatcliff, J., Danvy, O.: A generic account of continuation-passing styles. In: Proceedings of the 21st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 237–247 (1993) Google Scholar
  10. 10.
    Hofer, C., Ostermann, K.: On the relation of aspects and monads. In: Foundations of Aspect-Oriented Languages Workshop at AOSD, pp. 37–46 (2007) Google Scholar
  11. 11.
    Kiczales, G., Hilsdale, E., Hugunin, J., Kersten, M., Palm, J., Griswold, W.G.: An overview of aspectJ. In: ECOOP ’01: Proceedings of the 15th European Conference on Object-Oriented Programming. LNCS, vol. 2072, pp. 327–353 (2001) Google Scholar
  12. 12.
    Kishon, A.: Theory and art of semantics-directed program execution monitoring. Ph.D. thesis, Yale University (1992) Google Scholar
  13. 13.
    Kishon, A., Hudak, P.: Semantics directed program execution monitoring. J. Funct. Program. 5(4), 501–547 (1995) CrossRefGoogle Scholar
  14. 14.
    Lämmel, R.: Reuse by program transformation. In: Trends in Functional Programming, Selected Papers from the 1st Scottish Functional Programming Workshop, vol. 1, pp. 144–153 (1999) Google Scholar
  15. 15.
    Launchbury, J.: A natural semantics for lazy evaluation. In: Proceedings of the 20th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 144–154 (1993) CrossRefGoogle Scholar
  16. 16.
    Masuhara, H., Tatsuzawa, H., Yonezawa, A.: Aspectual Caml: an aspect-oriented functional language. In: ICFP ’05: Proceedings of the 10th ACM SIGPLAN International Conference on Functional Programming, New York, NY, USA, pp. 320–330 (2005) CrossRefGoogle Scholar
  17. 17.
    Meuter, W.D.: Monads as a theoretical foundation for AOP. In: International Workshop on Aspect-Oriented Programming at ECOOP (1997) Google Scholar
  18. 18.
    Oliveira, B.C.D.S., Schrijvers, T., Cook, W.R.: EffectiveAdvice: disciplined advice with explicit effects. In: ACM SIG Proceedings of the 9th International Conference on Aspect-Oriented Software Development (AOSD) (2010) Google Scholar
  19. 19.
    Wadler, P.: The essence of functional programming. In: Proceedings of the 19th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 1–14 (1992) CrossRefGoogle Scholar
  20. 20.
    Wang, M., Chen, K., Khoo, S.-C.: Type-directed weaving of aspects for higher-order functional languages. In: PEPM ’06: Workshop on Partial Evaluation and Program Manipulation, pp. 78–87 (2006) Google Scholar
  21. 21.
    Wang, M., Oliveira, B.C.D.S.: What does aspect-oriented programming mean for functional programmers. In: WGP ’09: Proceedings of the 2009 ACM SIGPLAN Workshop on Generic Programming, New York, NY, USA, pp. 37–48 (2009) CrossRefGoogle Scholar
  22. 22.
    Wansbrough, K., Peyton Jones, S.: Once upon a polymorphic type. In: 26th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 15–28 (1999) CrossRefGoogle Scholar

Copyright information

© Springer Science+Business Media, LLC 2011

Authors and Affiliations

  • Kung Chen
    • 1
    Email author
  • Shu-Chun Weng
    • 2
  • Jia-Yin Lin
    • 1
  • Meng Wang
    • 3
  • Siau-Cheng Khoo
    • 4
  1. 1.National Chengchi UniversityTaipei CityTaiwan
  2. 2.Yale UniversityNew HavenUSA
  3. 3.Oxford UniversityOxfordUK
  4. 4.National University of SingaporeSingaporeSingapore

Personalised recommendations