Combinators for impure yet hygienic code generation
Combinators for impure yet hygienic code generation
复制标题
用于生成不纯净但卫生的代码的组合器
DOI:
10.1016/j.scico.2015.08.007
复制
发表时间:
2015
影响因子:
1.3
通讯作者:
Chung-chieh Shan
中科院分区:
文献类型:
--
作者:
Yukiyoshi Kameyama;Oleg Kiselyov;Chung-chieh Shan
Code generation is the leading approach to making high-performance software reusable. Effects are indispensable in code generators, whether to report failures or to insert let-statements and if-guards. Extensive painful experience shows that unrestricted effects interact with generated binders in undesirable ways to produce unexpectedly unbound variables, or worse, unexpectedly bound ones. These subtleties hinder domain experts in using and extending the generator. A pressing problem is thus to express the desired effects while regulating them so that the generated code is correct, or at least correctly scoped, by construction.We present a code-combinator framework that lets us express arbitrary monadic effects, including mutable references and delimited control, that move open code across generated binders. The static types of our generator expressions not only ensure that a well-typed generator produces well-typed and well-scoped code. They also express the lexical scopes of generated binders and prevent mixing up variables with different scopes. For the first time ever we demonstrate statically safe and well-scoped loop exchange and constant factoring from arbitrarily nested loops.Our framework is implemented as a Haskell library that embeds an extensible typed higher-order domain-specific language. It may be regarded as `staged Haskell.' To become practical, the library relies on higher-order abstract syntax and polymorphism over generated type environments, and is written in the mature language.
登录
查看更多内容
DOI:
10.1007/11561347_18
发表时间:
2005
期刊:
--
影响因子:
--
作者:
J. Carette;O. Kiselyov
通讯作者:
O. Kiselyov
DOI:
10.1145/1863543.1863575
发表时间:
2010
期刊:
ACM SIGPLAN International Conference on Functional Programming
影响因子:
--
作者:
N. Pouillard;F. Pottier
通讯作者:
F. Pottier
DOI:
10.1007/978-3-642-32202-0
发表时间:
2012
期刊:
--
影响因子:
--
作者:
J. Gibbons
通讯作者:
J. Gibbons
DOI:
--
发表时间:
2014
期刊:
--
影响因子:
--
作者:
Jurriaan Hage
通讯作者:
Jurriaan Hage
DOI:
10.1007/978-3-642-32202-0_3
发表时间:
2010
期刊:
ArXiv
影响因子:
--
作者:
O. Kiselyov
通讯作者:
O. Kiselyov