CPL - Chalmers Publication Library
| Utbildning | Forskning | Styrkeområden | Om Chalmers | In English In English Ej inloggad.

Attribute Grammars Fly First-Class How to do Aspect Oriented Programming in Haskell

M. Viera ; S. D. Swierstra ; Wouter Swierstra (Institutionen för data- och informationsteknik, Programvaruteknik (Chalmers))
ACM Sigplan Notices (0362-1340). Vol. 44 (2009), 9, p. 245-256.
[Artikel, refereegranskad vetenskaplig]

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., type-class 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.

Nyckelord: Design, Languages, Performance, Standardization, Attribute Grammars, Class system, Lazy evaluation, Type-level programming, Haskell, HList



Denna post skapades 2010-02-25. Senast ändrad 2012-02-29.
CPL Pubid: 114914

 

Institutioner (Chalmers)

Institutionen för data- och informationsteknik, Programvaruteknik (Chalmers) (2008-2010)

Ämnesområden

Information Technology

Chalmers infrastruktur