Advertisement

Effective Aspects: A Typed Monadic Embedding of Pointcuts and Advice

  • Ismael Figueroa
  • Nicolas Tabareau
  • Éric Tanter
Chapter
Part of the Lecture Notes in Computer Science book series (LNCS, volume 8400)

Abstract

Aspect-oriented programming (AOP) aims to enhance modularity and reusability in software systems by offering an abstraction mechanism to deal with crosscutting concerns. However, in most general-purpose aspect languages aspects have almost unrestricted power, eventually conflicting with these goals. In this work we present Effective Aspects: a novel approach to embed the pointcut/advice model of AOP in a statically typed functional programming language like Haskell. Our work extends EffectiveAdvice, by Oliveira, Schrijvers, and Cook; which lacks quantification, and explores how to exploit the monadic setting in the full pointcut/advice model. Type soundness is guaranteed by exploiting the underlying type system, in particular phantom types and a new anti-unification type class. Aspects are first-class, can be deployed dynamically, and the pointcut language is extensible, therefore combining the flexibility of dynamically typed aspect languages with the guarantees of a static type system. Monads enables us to directly reason about computational effects both in aspects and base programs using traditional monadic techniques. Using this we extend Aldrich’s notion of Open Modules with effects, and also with protected pointcut interfaces to external advising. These restrictions are enforced statically using the type system. Also, we adapt the techniques of EffectiveAdvice to reason about and enforce control flow properties. Moreover, we show how to control effect interference using the parametricity-based approach of EffectiveAdvice. However, this approach falls short when dealing with interference between multiple aspects. We propose a different approach using monad views, a recently developed technique for handling the monad stack. Finally, we exploit the properties of our monadic weaver to enable the modular construction of new semantics for aspect scoping and weaving. These semantics also benefit fully from the monadic reasoning mechanisms present in the language. This work brings type-based reasoning about effects for the first time in the pointcut/advice model, in a framework that is both expressive and extensible; thus allowing development of robust aspect-oriented systems as well as being a useful research tool for experimenting with new aspect semantics.

Keywords

aspect-oriented programming monads pointcut/advice model type-based reasoning modular reasoning 

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    In: Proceedings of the 11th Workshop on Foundations of Aspect-Oriented Languages (FOAL 2012), Potsdam, Germany. ACM Press (March 2012)Google Scholar
  2. 2.
    Aldrich, J.: Open modules: Modular reasoning about advice. In: Gao, X.-X. (ed.) ECOOP 2005. LNCS, vol. 3586, pp. 144–168. Springer, Heidelberg (2005)CrossRefGoogle Scholar
  3. 3.
    In: Proceedings of the 7th ACM International Conference on Aspect-Oriented Software Development (AOSD 2008), Brussels, Belgium. ACM Press (April 2008)Google Scholar
  4. 4.
    In: Proceedings of the 9th ACM International Conference on Aspect-Oriented Software Development (AOSD 2010), Rennes and Saint Malo, France. ACM Press (March 2010)Google Scholar
  5. 5.
    Bagherzadeh, M., Rajan, H., Leavens, G.T., Mooney, S.: Translucid contracts: Expressive specification and modular verification for aspect-oriented interfaces. In: Proceedings of the 10th ACM International Conference on Aspect-Oriented Software Development (AOSD 2011), Porto de Galinhas, Brazil. ACM Press (March 2011)Google Scholar
  6. 6.
    Dantas, D.S., Walker, D.: Harmless advice. In: Proceedings of the 33rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL 2006), Charleston, South Carolina, pp. 383–396. ACM Press (January 2006)Google Scholar
  7. 7.
    Dantas, D.S., Walker, D., Washburn, G., Weirich, S.: AspectML: A polymorphic aspect-oriented functional programming language. ACM Transactions on Programming Languages and Systems 30(3), Article No. 14 (May 2008)Google Scholar
  8. 8.
    De Fraine, B., Südholt, M., Jonckers, V.: StrongAspectJ: flexible and safe pointcut/advice bindings. In: AOSD 2008 [3], pp. 60–71Google Scholar
  9. 9.
    Douence, R., Fradet, P., Südholt, M.: Trace-based aspects. In: Filman, R.E., Elrad, T., Clarke, S., Akşit, M. (eds.) Aspect-Oriented Software Development, pp. 201–217. Addison-Wesley, Boston (2005)Google Scholar
  10. 10.
    Douence, R., Motelet, O., Südholt, M.: A formal definition of crosscuts. In: Matsuoka, S. (ed.) Reflection 2001. LNCS, vol. 2192, pp. 170–186. Springer, Heidelberg (2001)CrossRefGoogle Scholar
  11. 11.
    Dutchyn, C., Tucker, D.B., Krishnamurthi, S.: Semantics and scoping of aspects in higher-order languages. Science of Computer Programming 63(3), 207–239 (2006)CrossRefzbMATHMathSciNetGoogle Scholar
  12. 12.
    Figueroa, I., Tabareau, N., Tanter, É.: Taming aspects with monads and membranes. In: Proceedings of the 12th Workshop on Foundations of Aspect-Oriented Languages (FOAL 2013), Fukuoka, Japan, pp. 1–6. ACM Press (March 2013)Google Scholar
  13. 13.
    Figueroa, I., Tanter, É.: A semantics for execution levels with exceptions. In: Proceedings of the 10th Workshop on Foundations of Aspect-Oriented Languages (FOAL 2011), Porto de Galinhas, Brazil, pp. 7–11. ACM Press (March 2011)Google Scholar
  14. 14.
    Figueroa, I., Tanter, É., Tabareau, N.: A practical monadic aspect weaver. In: Proceedings of the 11th Workshop on Foundations of Aspect-Oriented Languages (FOAL 2012), pp. 21–26 (2012)Google Scholar
  15. 15.
    Hilsdale, E., Hugunin, J.: Advice weaving in AspectJ. In: Lieberherr, K. (ed.) Proceedings of the 3rd ACM International Conference on Aspect-Oriented Software Development (AOSD 2004), Lancaster, UK, pp. 26–35. ACM Press (March 2004)Google Scholar
  16. 16.
    Hofer, C., Ostermann, K.: On the relation of aspects and monads. In: Proceedings of AOSD Workshop on Foundations of Aspect-Oriented Languages (FOAL 2007), pp. 27–33 (2007)Google Scholar
  17. 17.
    Jones, M.P.: Type classes with functional dependencies. In: Smolka, G. (ed.) ESOP 2000. LNCS, vol. 1782, pp. 230–244. Springer, Heidelberg (2000)CrossRefGoogle Scholar
  18. 18.
    Kiczales, G., Hilsdale, E., Hugunin, J., Kersten, M., Palm, J., Griswold, W.G.: An overview of aspectJ. In: Lindskov Knudsen, J. (ed.) ECOOP 2001. LNCS, vol. 2072, pp. 327–353. Springer, Heidelberg (2001)CrossRefGoogle Scholar
  19. 19.
    Kiczales, G., Lamping, J., Mendhekar, A., Maeda, C., Lopes, C.V., Loingtier, J.-M., Irwin, J.: Aspect-oriented programming. In: Akşit, M., Matsuoka, S. (eds.) ECOOP 1997. LNCS, vol. 1241, pp. 220–242. Springer, Heidelberg (1997)CrossRefGoogle Scholar
  20. 20.
    Learn you a haskell website (2013), http://learnyouahaskell.com/
  21. 21.
    Leijen, D., Meijer, E.: Domain specific embedded compilers. In: Ball, T. (ed.) Proceedings of the 2nd USENIX Conference on Domain-Specific Languages, pp. 109–122 (1999)Google Scholar
  22. 22.
    Liang, S., Hudak, P., Jones, M.: Monad transformers and modular interpreters. In: Proceedings of the 22nd ACM Symposium on Principles of Programming Languages (POPL 95), San Francisco, California, USA, pp. 333–343. ACM Press (1995)Google Scholar
  23. 23.
    Hansen, K.A., Kawauchi, K.: Dataflow pointcut in aspect-oriented programming. In: Ohori, A. (ed.) APLAS 2003. LNCS, vol. 2895, pp. 105–121. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  24. 24.
    Hansen, K.A., Kiczales, G., Dutchyn, C.: A compilation and optimization model for aspect-oriented programs. In: Hedin, G. (ed.) CC 2003. LNCS, vol. 2622, pp. 46–60. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  25. 25.
    Masuhara, H., Tatsuzawa, H., Yonezawa, A.: Aspectual Caml: an aspect-oriented functional language. In: Proceedings of the 10th ACM SIGPLAN Conference on Functional Programming (ICFP 2005), Tallin, Estonia, pp. 320–330. ACM Press (September 2005)Google Scholar
  26. 26.
    Meuter, W.D.: Monads as a theoretical foundation for aop. In: International Workshop on Aspect-Oriented Programming at ECOOP, p. 25. Springer (1997)Google Scholar
  27. 27.
    Moggi, E.: Notions of computation and monads. Information and Computation 93(1), 55–92 (1991)CrossRefzbMATHMathSciNetGoogle Scholar
  28. 28.
    Oliveira, B.C.D.S., Schrijvers, T., Cook, W.R.: EffectiveAdvice: discplined advice with explicit effects. In: AOSD 2010 [4], pp. 109–120Google Scholar
  29. 29.
    Oliveira, B.C.D.S., Schrijvers, T., Cook, W.R.: MRI: Modular reasoning about interference in incremental programming. Journal of Functional Programming 22, 797–852 (2012)CrossRefzbMATHMathSciNetGoogle Scholar
  30. 30.
    Peyton Jones, S., Vytiniotis, D., Weirich, S., Shields, M.: Practical type inference for arbitrary-rank types. Journal of Functional Programming 17(1), 1–82 (2007)CrossRefzbMATHMathSciNetGoogle Scholar
  31. 31.
    Pierce, B.C.: Types and programming languages. MIT Press, Cambridge (2002)Google Scholar
  32. 32.
    Plotkin, G.D.: A note on inductive generalization. Machine Intelligence 5, 153–163 (1970)MathSciNetGoogle Scholar
  33. 33.
    Reynolds, J.C.: Transformational systems and the algebraic structure of atomic formulas. Machine Intelligence 5, 135–151 (1970)Google Scholar
  34. 34.
    Rinard, M., Salcianu, A., Bugrara, S.: A classification system and analysis for aspect-oriented programs. In: Proceedings of the 12th ACM Symposium on Foundations of Software Engineering (FSE 12), pp. 147–158. ACM Press (2004)Google Scholar
  35. 35.
    Schrijvers, T., Oliveira, B.C.: Monads, zippers and views: virtualizing the monad stack. In: Proceedings of the 16th ACM SIGPLAN Conference on Functional Programming (ICFP 2011), Tokyo, Japan, pp. 32–44. ACM Press (September 2011)Google Scholar
  36. 36.
    Sheard, T., Jones, S.P.: Template meta-programming for haskell. SIGPLAN Not. 37(12), 60–75 (2002)CrossRefGoogle Scholar
  37. 37.
    Sulzmann, M., Wang, M.: Aspect-oriented programming with type classes. In: Proceedings of the Sixth Workshop on Foundations of Aspect-Oriented Languages (FOAL 2007), Vancouver, British Columbia, Canada, pp. 65–74. ACM Press (2007)Google Scholar
  38. 38.
    Tabareau, N.: A monadic interpretation of execution levels and exceptions for AOP. In: Tanter, É., Sullivan, K.J. (eds.) Proceedings of the 11th International Conference on Aspect-Oriented Software Development (AOSD 2012), Potsdam, Germany. ACM Press (March 2012)Google Scholar
  39. 39.
    Tabareau, N., Figueroa, I., Tanter, É.: A typed monadic embedding of aspects. In: Kinzle, J. (ed.) Proceedings of the 12th International Conference on Aspect-Oriented Software Development (AOSD 2013), Fukuoka, Japan, pp. 171–184. ACM Press (March 2013)Google Scholar
  40. 40.
    Tanter, É.: Expressive scoping of dynamically-deployed aspects. In: AOSD 2008 [3], pp. 168–179Google Scholar
  41. 41.
    Tanter, É.: Execution levels for aspect-oriented programming. In: AOSD 2010 [4], pp. 37–48Google Scholar
  42. 42.
    Tanter, É., Figueroa, I., Tabareau, N.: Execution levels for aspect-oriented programming: Design, semantics, implementations and applications. Science of Computer Programming (2013) (available online)Google Scholar
  43. 43.
    Tanter, É., Moret, P., Binder, W., Ansaloni, D.: Composition of dynamic analysis aspects. In: Proceedings of the 9th ACM SIGPLAN International Conference on Generative Programming and Component Engineering (GPCE 2010), Eindhoven, The Netherlands, pp. 113–122. ACM Press (October 2010)Google Scholar
  44. 44.
    Tanter, É., Tabareau, N., Douence, R.: Taming aspects with membranes. In: Proceedings of the 11th Workshop on Foundations of Aspect-Oriented Languages (FOAL 2012) [1], pp. 3–8Google Scholar
  45. 45.
    Toledo, R., Leger, P., Tanter, É.: AspectScript: Expressive aspects for the Web. In: AOSD 2010 [4], pp. 13–24Google Scholar
  46. 46.
    Wadler, P.: The essence of functional programming. In: Proceedings of the 19th ACM Symposium on Principles of Programming Languages (POPL 1992), Albuquerque, New, Mexico, USA, pp. 1–14. ACM Press (January 1992)Google Scholar
  47. 47.
    Wadler, P., Blott, S.: How to make ad-hoc polymorphism less ad hoc. In: Proceedings of the 16th ACM Symposium on Principles of Programming Languages (POPL 1989), Austin, TX, USA, pp. 60–76. ACM Press (January 1989)Google Scholar
  48. 48.
    Wand, M., Kiczales, G., Dutchyn, C.: A semantics for advice and dynamic join points in aspect-oriented programming. ACM Transactions on Programming Languages and Systems 26(5), 890–910 (2004)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2014

Authors and Affiliations

  • Ismael Figueroa
    • 1
    • 2
  • Nicolas Tabareau
    • 2
  • Éric Tanter
    • 1
  1. 1.PLEIAD LaboratoryUniversity of ChileSantiagoChile
  2. 2.ASCOLA GroupINRIA – NantesFrance

Personalised recommendations