How to write a quasicycler in terms of another quasicyclic

If I work with a third-party quasi-cycler, for example thirdParty :: QuasiQuoter, and I want to write my own in terms of this quasi-cycle, how can 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 does not tell me that the abstract syntax tree is for "[thirdParty | |]", so it seems that I cannot build such a patten with the Haskell pattern.

+4
source share
1 answer

The answer is easy to handle, and I thought about it when I finished asking the question. There QuasiQuoteris nothing magical about it. This is a simple old boring algebraic data type! Just do:

myQuasiQuoter = QuasiQuoter { quoteExp = f (quoteExp thirdParty) }

f - , . quotePat, quoteType quoteDec, .

+4

All Articles