PLDI '94 Proceedings of the ACM SIGPLAN 1994 conference on Programming language design and implementation
Science of Computer Programming - Special issue on mathematics of program construction
Type-safe cast: (functional pearl)
ICFP '00 Proceedings of the fifth ACM SIGPLAN international conference on Functional programming
Proceedings of the sixth ACM SIGPLAN international conference on Functional programming
Proceedings of the seventh ACM SIGPLAN international conference on Functional programming
Implementing typeful program transformations
Proceedings of the 2003 ACM SIGPLAN workshop on Partial evaluation and semantics-based program manipulation
Type-safe, self inspecting code
Haskell '04 Proceedings of the 2004 ACM SIGPLAN workshop on Haskell
Simple unification-based type inference for GADTs
Proceedings of the eleventh ACM SIGPLAN international conference on Functional programming
Haskell, do you read me?: constructing and composing efficient top-down parsers at runtime
Proceedings of the first ACM SIGPLAN symposium on Haskell
Lazy functional incremental parsing
Proceedings of the 2nd ACM SIGPLAN symposium on Haskell
Typed Transformations of Typed Grammars: The Left Corner Transform
Electronic Notes in Theoretical Computer Science (ENTCS)
MPC'10 Proceedings of the 10th international conference on Mathematics of program construction
Explicitly recursive grammar combinators: a better model for shallow parser DSLs
PADL'11 Proceedings of the 13th international conference on Practical aspects of declarative languages
A lean specification for GADTs: system F with first-class equality proofs
Higher-Order and Symbolic Computation
SBLP'12 Proceedings of the 16th Brazilian conference on Programming Languages
Grammar fragments fly first-class
Proceedings of the Twelfth Workshop on Language Descriptions, Tools, and Applications
Hi-index | 0.00 |
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.