Sebastian Erdweg, Felix Rieger, Tillmann Rendel, and Klaus Ostermann, to appear in Proc. of Haskell Symposium, 2012.
Programmers need convenient syntax to write elegant and concise programs. Consequently, the Haskell standard provides syntactic sugar for some scenarios (e.g., do notation for monadic code), authors of Haskell compilers provide syntactic sugar for more scenarios (e.g., arrow notation in GHC), and some Haskell programmers implement preprocessors for their individual needs (e.g., idiom brackets in SHE). But manually written preprocessors cannot scale: They are expensive, error-prone, and not composable. Most researchers and programmers therefore refrain from using the syntactic notations they need in actual Haskell programs, but only use them in documentation or papers. We present a syntactically extensible version of Haskell, SugarHaskell, that empowers ordinary programmers to implement and use custom syntactic sugar.
Building on our previous work on syntactic extensibility for Java, SugarHaskell integrates syntactic extensions as sugar libraries into Haskell’s module system. Syntax extensions in SugarHaskell can declare arbitrary context-free and layout-sensitive syntax. SugarHaskell modules are compiled into Haskell modules and further processed by a Haskell compiler. We provide an Eclipse-based IDE for SugarHaskell that is extensible, too, and automatically provides syntax coloring for all syntax extensions imported into a module.
Paper describes an approach to extensible Haskell syntax. The whole concept looks like it could be integrated to GHC with language extension mechanism, which is easier to use than external preprocessor (though it is written in Java). When comparing to TemplateHaskell, authors emphasize that their extension is modular and composable, what cannot be said about TH. Sources on GitHub.
Recent comments
22 weeks 6 days ago
23 weeks 3 hours ago
23 weeks 3 hours ago
45 weeks 1 day ago
49 weeks 3 days ago
51 weeks 11 hours ago
51 weeks 11 hours ago
1 year 1 week ago
1 year 6 weeks ago
1 year 6 weeks ago