Aspect AG
Center
Submitted to PEPM 2012
Title : UUAG Meets
AspectAG: How to make Attribute Grammars First-Class
Authors : Marcos Viera, S. Doaitse Swierstra, Arie Middelkoop
Benchmarks :
Benchmarks
Title : Attribute Grammars Fly First-Class: How to do aspect oriented programming in Haskell
Authors : Marcos Viera, S. Doaitse Swierstra, Wouter S. Swierstra
Abstract : Attribute Grammars (AGs), a general-purpose formalism for describing
recursive computations over data types, avoid the trade-off
which arises when building software incrementally: should it be
easy to add new data types and data type alternatives or to add new
operations on existing data types? However, AGs are usually implemented
as a pre-processor, leaving e.g. type checking to later
processing phases and making interactive development, proper error
reporting and debugging difficult. Embedding AG into Haskell
as a combinator library solves these problems.
Previous attempts at embedding AGs as a domain-specific
language were based on extensible records and thus exploiting
Haskell’s type system to check the well-formedness of the AG, but
fell short in compactness and the possibility to abstract over oft occurring
AG patterns. Other attempts used a very generic mapping
for which the AG well-formedness could not be statically checked.
We present a typed embedding of AG in Haskell satisfying all
these requirements. The key lies in using HList-like typed heterogeneous
collections (extensible polymorphic records) and expressing
AG well-formedness conditions as type-level predicates (i.e., typeclass
constraints). By further type-level programming we can also
express common programming patterns, corresponding to the typical
use cases of monads such as Reader, Writer and State. The
paper presents a realistic example of type-class-based type-level
programming in Haskell.
Full Text :
pdf
Slides :
pdf
BibTeX :
bib
Package :
AspectAG (includes examples)