Aspect-oriented programming with type classes

We consider the problem of adding aspects to a strongly typed language which supports type classes. We show that type classes as supported by the Glasgow Haskell Compiler can model an AOP style of programming via a simple syntax-directed transformation scheme where AOP programming idioms are mapped to type classes. The drawback of this approach is that we cannot easily advise functions in programs which carry type annotations. We sketch a more principled approach which is free of such problems by combining ideas from intentional type analysis with advanced overloading resolution strategies. Our results show that type-directed static weaving is closely related to type class resolution -- the process of typing and translating type class programs.

[1]  Philip Wadler,et al.  How to make ad-hoc polymorphism less ad hoc , 1989, POPL '89.

[2]  Simon L. Peyton Jones,et al.  Sound and Decidable Type Inference for Functional Dependencies , 2004, ESOP.

[3]  Arabellastrasse,et al.  Constraint Handling Rules ? , 1995 .

[4]  Ralf Lämmel,et al.  Scrap your boilerplate: a practical approach to generic programming , 2003 .

[5]  Mark P. Jones A system of constructor classes: overloading and implicit higher-order polymorphism , 1993, FPCA '93.

[6]  Peyton Jones,et al.  Haskell 98 language and libraries : the revised report , 2003 .

[7]  David Walker,et al.  A theory of aspects , 2003, ICFP '03.

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

[9]  Siau-Cheng Khoo,et al.  On The Pursuit of Staticness and Coherence , 2006 .

[10]  Stephanie Weirich,et al.  Good advice for type-directed programming aspect-oriented programming and extensible generic functions , 2006, WGP '06.

[11]  Satish R. Thatte Semantics of type classes revisited , 1994, LFP '94.

[12]  Fritz Henglein,et al.  Type inference with polymorphic recursion , 1993, TOPL.

[13]  Peter J. Stuckey,et al.  Principal Type Inference for GHC-Style Multi-parameter Type Classes , 2006, APLAS.

[14]  Thierry Coquand,et al.  Inheritance as Implicit Coercion , 1991, Inf. Comput..

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

[16]  Simon L. Peyton Jones,et al.  Template meta-programming for Haskell , 2002, Haskell '02.

[17]  J. A. Robinson,et al.  A Machine-Oriented Logic Based on the Resolution Principle , 1965, JACM.

[18]  Simon Peyton Jones,et al.  Type classes: an exploration of the design space , 1997 .

[19]  Simon L. Peyton Jones,et al.  Scrap your boilerplate: a practical design pattern for generic programming , 2003, TLDI '03.

[20]  Gregor Kiczales,et al.  A semantics for advice and dynamic join points in aspect-oriented programming , 2001, TOPL.

[21]  David Walker,et al.  PolyAML: a polymorphic aspect-oriented functional programming language , 2005, ICFP '05.

[22]  Robert Harper,et al.  Compiling polymorphism using intensional type analysis , 1995, POPL '95.

[23]  Stefan Kaes,et al.  Parametric Overloading in Polymorphic Programming Languages , 1988, ESOP.

[24]  Simon L. Peyton Jones,et al.  System F with type equality coercions , 2007, TLDI '07.

[25]  Ralf Lämmel,et al.  A semantical approach to method-call interception , 2002, AOSD '02.

[26]  Mark P. Jones,et al.  Type Classes with Functional Dependencies , 2000, ESOP.

[27]  Simon L. Peyton Jones,et al.  Understanding functional dependencies via constraint handling rules , 2007, J. Funct. Program..

[28]  Simon L. Peyton Jones,et al.  Type classes in Haskell , 1994, TOPL.

[29]  Ralf Lämmel,et al.  Strongly typed heterogeneous collections , 2004, Haskell '04.

[30]  Paul Hudak,et al.  Monad transformers and modular interpreters , 1995, POPL '95.

[31]  Shriram Krishnamurthi,et al.  Pointcuts and advice in higher-order languages , 2003, AOSD '03.

[32]  Simon L. Peyton Jones,et al.  Simple unification-based type inference for GADTs , 2006, ICFP '06.

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