Skip to main content
Log in

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

  • Published:
Higher-Order and Symbolic Computation

Abstract

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.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Similar content being viewed by others

References

  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)

    Chapter  Google Scholar 

  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. 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)

    Article  Google Scholar 

  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)

    Chapter  Google Scholar 

  5. Erwig, M., Ren, D.: Monadification of functional programs. Sci. Comput. Program. 52(1–3), 101–129 (2004)

    Article  MathSciNet  MATH  Google Scholar 

  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)

    Chapter  Google Scholar 

  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)

    Chapter  Google Scholar 

  8. Functional Programming Group, K. U.: Monadification as a refactoring (2005)

  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. 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. 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. Kishon, A.: Theory and art of semantics-directed program execution monitoring. Ph.D. thesis, Yale University (1992)

  13. Kishon, A., Hudak, P.: Semantics directed program execution monitoring. J. Funct. Program. 5(4), 501–547 (1995)

    Article  Google Scholar 

  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. 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)

    Chapter  Google Scholar 

  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)

    Chapter  Google Scholar 

  17. Meuter, W.D.: Monads as a theoretical foundation for AOP. In: International Workshop on Aspect-Oriented Programming at ECOOP (1997)

    Google Scholar 

  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. 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)

    Chapter  Google Scholar 

  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. 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)

    Chapter  Google Scholar 

  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)

    Chapter  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Kung Chen.

Additional information

This is an extension of the work presented at the ACM SIGPLAN 2009 Workshop on Partial Evaluation and Program Manipulation (PEPM’09).

Rights and permissions

Reprints and permissions

About this article

Cite this article

Chen, K., Weng, SC., Lin, JY. et al. Side-effect localization for lazy, purely functional languages via aspects. Higher-Order Symb Comput 24, 151–189 (2011). https://doi.org/10.1007/s10990-011-9073-0

Download citation

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s10990-011-9073-0

Keywords

Navigation