Well, the question is self-explicative. Suppose I want to implement some special syntax just for fun. Is it possible? What tools should I use?
Syntactic sugar refers to any redundant type of syntax in a programming language that is redundant to the main syntax but which (hopefully) makes the code easier to understand or write.
do { putStr "Hello" ; putStr " " ; putStr "world!" ; putStr "\n" } (using the optional braces and semicolons explicitly, for clarity). This sequence of instructions nearly matches that in any imperative language. In Haskell, we can chain any actions as long as all of them are in the same monad.
There is no such meta-syntax in the Haskell standard, but there is in GHC. You can make almost any notation you want using the GHC "quasi-quotation" facilities (which are different from GHC's "Template Haskell" facility).
The GHC user guide on this is quite short, and mainly points to haskell wiki page on Quasiquotation and the implementor's home page, both of these point to the original publication: "Why It’s Nice to be Quoted: Quasiquoting for Haskell".
People have used quasi-quotation for embedding XML syntax, regular expressions, special string and text forms, and in "JMacro is a library for the programmatic generation of Javascript code."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With