On Feb 3, 2010, at 1:48 AM, Max Bolingbroke wrote:

2010/2/2 Twan van Laarhoven <twa...@gmail.com>:
   class Quoted a where
       parseQuote :: String -> a
       -- for performance reasons:
       parseQuote' :: Ghc.PackedString -> a

Great idea!

Thinking about it, you can use type classes to dispose of the
QuasiQuote record entirely. Instead, have:

class MyLang a where
 myLang :: String -> Q a

instance MyLang Exp where
 myLang = myLangSyntaxToGHCExprForSplice . myLangExpParser

... etc, MyLang instances for Pat and Type too ...

With a class-based approach only one parser that creates values of the same type could be used in a program. It would not be possible to embed multiple languages that create TH.Exp to be spliced into a single program. With the current syntax, I can write [$myLang| ... |] and [$yourLang| ... |] in the same program and use different parsers although both create Exp values.

And then write:

$(myLang [|...|])

This is more verbose than the proposed [myLang| ... |]. There seem to be different goals in the different proposals in this thread: 1. Simplify the syntax for quasi quoting (remove $, use different brackets), 2. make it more generally applicable (allow declarations and/or types to be quasi quoted), and 3. simplify and generalise its implementation (invent a single mechanism that unifies quasi quoting and TH splicing).

Sebastian

--
Underestimating the novelty of the future is a time-honored tradition.
(D.G.)



_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to