ACM Home Page
Please provide us with feedback. Feedback
Digital Library logoTake a look at the new version of this page: [ beta version ]. Tell us what you think.
Typed transformations of typed abstract syntax
Full text PdfPdf (601 KB)
Source
Types In Languages Design And Implementation archive
Proceedings of the 4th international workshop on Types in language design and implementation table of contents
Savannah, GA, USA
SESSION: Session 1 table of contents
Pages: 15-26  
Year of Publication: 2009
ISBN:978-1-60558-420-1
Authors
Arthur I. Baars  Universidad Politécnica de Valencia, Valencia, Spain
S. Doaitse Swierstra  Utrecht University, UTRECHT, Netherlands
Marcos Viera  Universidad de la República, Montevideo, Uruguay
Sponsors
SIGPLAN: ACM Special Interest Group on Programming Languages
ACM: Association for Computing Machinery
Publisher
ACM  New York, NY, USA
Bibliometrics
Downloads (6 Weeks): 8,   Downloads (12 Months): 76,   Citation Count: 1
Additional Information:

abstract   references   cited by   index terms   collaborative colleagues  

Tools and Actions: Request Permissions Request Permissions    Review this Article  
DOI Bookmark: Use this link to bookmark this Article: http://doi.acm.org/10.1145/1481861.1481865
What is a DOI?

ABSTRACT

Advantages of embedded domain-specific languages (EDSLs) are that one does not have to implement a separate type system nor an abstraction mechanism, since these are directly borrowed from the host language. Straightforward implementations of embedded domain-specific languages map the semantics of the embedded language onto a function in the host language. The semantic mappings are usually compositional, i.e. they directly follow the syntax of the embedded language.

One of the questions which arises is whether conventional compilation techniques, such as global analysis and resulting transformations, can be applied in the context of EDSLs. The approach we take is that, instead of mapping the embedded language directly onto a function, we first build a representation of the abstract syntax tree of the embedded program fragment. This syntax tree is subsequently analyzed and transformed, and finally mapped onto a function representing its denotational semantics. In this way we achieve run-time "compilation" of the embedded language.

Run-time transformations on the embedded language can have a huge effect on performance. In previous work we present a case study comparing the Read instances generated by Haskells deriving construct with instances on which run-time grammar transformations (precedence resolution, left-factorisation and left-corner transformation) have been applied.

In this paper we present the library, which has an arrow like interface, which supports in the construction of analyses and transformations, and we demonstrate its use in implementing a common sub-expression elemination transformation. The library uses typed abstract syntax to represent fragments of embedded programs containing variables and binding structures, while preserving the idea that the type system of the host language is used to emulate the type system of the embedded language. The tricky issue is how to keep a collection of mutually recursive structures well-typed while it is being transformed.

We finally discuss the typing rules of Haskell, its extensions and those as implemented by the GHC and show that pure System-F based systems are sufficiently rich to express what we want to express, albeit at the cost of an increased complexity of the code.


REFERENCES

Note: OCR errors may be found in this Reference List extracted from the full text article. ACM has opted to expose the complete List rather than only correct and linked references.

 
1
Arthur Baars and S. Doaitse Swierstra. Typed transformations of typed abstract syntax. UU-CS 21, Utrecht University, 2008.
2
3
 
4
Arthur I. Baars, S. Doaitse Swierstra, and Marcos Viera. TTTAS HackageDB package. URL http://hackage.haskell.org/cgi-bin/hackage-scripts/package/TTTAS.
5
 
6
James Cheney and Ralf Hinze. First-Class Phantom Types. Technical report TR2003-1901, Cornell University, 2003. http://techreports.library.cornell.edu:8081/Dienst/UI/1.0/Display/cul.c%is/TR2003-1901.
 
7
EHC. Essential haskell compiler. URL http://www.cs.uu.nl/wiki/Ehc.
 
8
GHC. Glasgow haskell compiler. URL http://www.haskell.org/ghc/.
 
9
Hackage. Hackage. URL http://hackage.haskell.org/.
 
10
 
11
Hugs. Hugs. URL http://www.haskell.org/hugs/.
12
 
13
Emir Pasalic and Nathan Linger. Meta-programming with typed object-language representations. In Generative Programming and Component Engineering (GPCE'04), volume LNCS 3286, pages 136--167, October 2004.
14
15
16
17


Collaborative Colleagues:
Arthur I. Baars: colleagues
S. Doaitse Swierstra: colleagues
Marcos Viera: colleagues