Quasi quoting

Twan van Laarhoven twanvl at gmail.com
Tue Feb 2 17:21:21 EST 2010


Max Bolingbroke wrote:
> 2010/2/2 Isaac Dupree <ml at isaac.cedarswampstudios.org>:
>> I'm concerned in both your proposals, that single-letter names like "t" and
>> "d" are common function parameters, thus possibly producing
>> - shadowing warnings for all such functions in modules that happen to use TH
>> - errors, I think, for some uses of TH inside such functions (either the
>> function parameters must be renamed, or the TH splice module-qualified)
> 
> Yes, this is certainly an annoyance :-). However, we didn't have
> backcompat high up the list of priorities with these proposals -
> instead we wanted to look at how TH and QQ might be redesigned to work
> together a bit more neatly if we were starting with a clean slate
> today.
> 
> You can of course choose more expressive names than "e" and "t" if
> you're going to break backcompat anyway,

You could also do away with these names entirely, and use magic instead:

     instance IsString HsExpr where
         fromString = e

Or perhaps a different typeclass for [|...|] blocks,

     class Quoted a where
         parseQuote :: String -> a
         -- for performance reasons:
         parseQuote' :: Ghc.PackedString -> a


This also leaves the door open for constructions like:

     instance Quoted QuasiQuote where
         parseQuote xs = let (f,x) = splitAt '|' xs
                         in (findParserByName f) x

     f = $[|foo| ... |] -- we still have to register foo somehow


Twan


More information about the Glasgow-haskell-users mailing list