Attribute Grammars Fly First-Class How to do Aspect Oriented Programming in Haskell
Uložené v:
| Názov: | Attribute Grammars Fly First-Class How to do Aspect Oriented Programming in Haskell |
|---|---|
| Autori: | Viera, M., Swierstra, S. D., Swierstra, Wouter, 1981 |
| Zdroj: | SIGPLAN Notices (ACM Special Interest Group on Programming Languages). 44(9):245-256 |
| Predmety: | Performance, Standardization, HList, Class system, Attribute Grammars, Lazy evaluation, Languages, Design, Haskell, Type-level programming |
| Popis: | 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. |
| Prístupová URL adresa: | https://research.chalmers.se/publication/114914 |
| Databáza: | SwePub |
| Abstrakt: | 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. |
|---|---|
| ISBN: | 1605583324 9781605583327 |
| ISSN: | 07308566 |
| DOI: | 10.1145/1596550.1596586 |
Full Text Finder
Nájsť tento článok vo Web of Science