Created
June 6, 2017 21:35
-
-
Save joelburget/6ffffb44c31884561b74a0e2dd1c1a86 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- decls :: [Decl] | |
-- makeTables :: [Decl] -> Tables | |
quoteDeclarations :: String -> ExpQ | |
quoteDeclarations str = do | |
loc <- TH.location | |
Right decls <- pure $ runTokenParse parseDecls str | |
-- Antiquotation: must run before `makeTables` | |
let decls' = dataToExpQ (const Nothing `extQ` replaceVars) decls | |
-- problem here: | |
-- • GHC stage restriction: | |
-- ‘decls'’ is used in a top-level splice, quasi-quote, or annotation, | |
-- and must be imported, not defined locally | |
-- • In the untyped splice: $decls' | |
let tables = makeTables $(decls') | |
dataToExpQ | |
(const Nothing `extQ` handleByteString `extQ` handleText) | |
tables |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment