
2010/2/2 Twan van Laarhoven
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 ... And then write: $(myLang [|...|]) Now the splice $(e) typechecks e as a Q Type / Q Exp / Q Decl as required by the context it is in, and hence gets the correct instance of MyLang. So our proposal needn't change the semantics of splice at all - we can reuse the name overloading abilities of type classes. It's a shame that TH is too widely used to be amenable to refactoring into this sort of form. Cheers, Max