Aspect-Oriented Programming with Type Classes
Martin Sulzmann National University of Singapore Meng Wang Oxford University
Aspect-Oriented Programming with Type Classes – p.1
Aspect-Oriented Programming with Type Classes Martin Sulzmann - - PowerPoint PPT Presentation
Aspect-Oriented Programming with Type Classes Martin Sulzmann National University of Singapore Meng Wang Oxford University Aspect-Oriented Programming with Type Classes p.1 Whats this talk about? Aspect-oriented programming (AOP) is
Martin Sulzmann National University of Singapore Meng Wang Oxford University
Aspect-Oriented Programming with Type Classes – p.1
type classes ≈ C++ templates ≈ Java interfaces
Aspect-Oriented Programming with Type Classes – p.2
Aspect-Oriented Programming with Type Classes – p.3
Aspect-Oriented Programming with Type Classes – p.4
Aspect-Oriented Programming with Type Classes – p.5
Clumsy, we have to thread through leq.
Aspect-Oriented Programming with Type Classes – p.6
Aspect-Oriented Programming with Type Classes – p.7
Aspect-Oriented Programming with Type Classes – p.8
We only want to advise the relevant program parts.
Aspect-Oriented Programming with Type Classes – p.9
Aspect-Oriented Programming with Type Classes – p.10
We will see later how to encode AOP Haskell in Haskell.
Aspect-Oriented Programming with Type Classes – p.11
Aspect-Oriented Programming with Type Classes – p.12
N1@advice #insert# :: Ord a => a -> [a] -> [a] = \x -> \ys -> let zs = proceed x ys in if (isSorted ys) && (isSorted zs) then zs else error "Bug" where isSorted xs = (sort xs) == xs
N2@advice #insert# :: Int -> [Int] -> [Int] = ...
Aspect-Oriented Programming with Type Classes – p.13
Aspect-Oriented Programming with Type Classes – p.14
Aspect-Oriented Programming with Type Classes – p.15
We will shortly discuss the overlap among the instances
Aspect-Oriented Programming with Type Classes – p.16
Aspect-Oriented Programming with Type Classes – p.17
We need to take a look at type class resolution now.
Aspect-Oriented Programming with Type Classes – p.18
Aspect-Oriented Programming with Type Classes – p.19
Aspect-Oriented Programming with Type Classes – p.20
Aspect-Oriented Programming with Type Classes – p.21
Aspect-Oriented Programming with Type Classes – p.22
Unexpected behavior.
Aspect-Oriented Programming with Type Classes – p.23
Aspect-Oriented Programming with Type Classes – p.24
Aspect-Oriented Programming with Type Classes – p.25
Aspect-Oriented Programming with Type Classes – p.26
Type class resolution via forward chaining
Type class resolution via backward chaining/search
i
Aspect-Oriented Programming with Type Classes – p.27
Aspect-Oriented Programming with Type Classes – p.28
Aspect-Oriented Programming with Type Classes – p.29
Perform case analysis, i.e. solving by search.
Aspect-Oriented Programming with Type Classes – p.30
[DWWW05] D. S. Dantas, D. Walker, G. Washburn, and S. Weirich. PolyAML: a polymorphic aspect-oriented functional program- ming language. In Proc. of ICFP’05, pages 306–319. ACM Press, 2005. [KLS04]
ammel, and K. Schupke. Strongly typed het- erogeneous collections. In Haskell ’04: Proceedings of the 2004 ACM SIGPLAN workshop on Haskell, pages 96–107. ACM Press, 2004. [L¨ am02]
ence on Aspect-oriented software development, pages 41–55. ACM Press, 2002. [LP03]
ammel and S. Peyton Jones. Scrap your boilerplate: a practical approach to generic programming. In Proc. of ACM SIGPLAN Workshop on Types in Language Design and Imple- mentation (TLDI 2003), pages 26–37. ACM Press, 2003. [MTY05]
Aspectual caml: an aspect-oriented functional language. In Proc. of ICFP’05, pages 320–330. ACM Press, 2005. [TK03]
Pointcuts and advice in higher-order languages. In Proc. of AOSD’03, pages 158–167. ACM Press, 2003. [WCK06a]
and coherence. In FOAL ’06: Foundations of Aspect-Oriented Languages, 2006. 30-1
[WCK06b]
Type-directed weaving
PEPM ’06: Workshop on Partial Evaluation and Program Ma- nipulation, pages 78–87. ACM Press, 2006. [WKD04]
and dynamic join points in aspect-oriented programming. ACM
[WZL03]
30-2