Reputation: 1166
If I'm working with a third party quasi-quoter, for example thirdParty :: QuasiQuoter
, and I want to write my own in terms of this quasi-quoter, how do I do this? In ghci I tried
runQ [| [thirdParty| |] |]
But this outputs (in my case):
LamE [VarP _render_2] (AppE (VarE GHC.Base.return) (ConE GHC.Tuple.()))
Which doesn't tell me what the abstract syntax tree for "[thirdParty| |]" is so it seems I can't construct such a patten with template Haskell.
Upvotes: 5
Views: 76
Reputation: 1166
The answer is face-palmingly simple and I thought of it the moment I finished asking the question. There is nothing magical about QuasiQuoter
. It's a plain old boring algebraic data type! Just do:
myQuasiQuoter = QuasiQuoter { quoteExp = f (quoteExp thirdParty) }
Where f
is a function that transforms quasi-quoter as required. Do the same thing for quotePat
, quoteType
, and quoteDec
if required.
Upvotes: 5