diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2019-11-27 15:29:44 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-01-12 21:28:47 -0500 |
commit | 9129210f7e9937c1065330295f06524661575839 (patch) | |
tree | 8eee18f92d23eb2fe39adecda1d547fa8d9fa7cb /testsuite/tests/plugins/simple-plugin | |
parent | 49f83a0de12a7c02f4a6e99d26eaa362a373afa5 (diff) | |
download | haskell-9129210f7e9937c1065330295f06524661575839.tar.gz |
Overloaded Quotation Brackets (#246)
This patch implements overloaded quotation brackets which generalise the
desugaring of all quotation forms in terms of a new minimal interface.
The main change is that a quotation, for example, [e| 5 |], will now
have type `Quote m => m Exp` rather than `Q Exp`. The `Quote` typeclass
contains a single method for generating new names which is used when
desugaring binding structures.
The return type of functions from the `Lift` type class, `lift` and `liftTyped` have
been restricted to `forall m . Quote m => m Exp` rather than returning a
result in a Q monad.
More details about the feature can be read in the GHC proposal.
https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0246-overloaded-bracket.rst
Diffstat (limited to 'testsuite/tests/plugins/simple-plugin')
-rw-r--r-- | testsuite/tests/plugins/simple-plugin/Simple/RemovePlugin.hs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/testsuite/tests/plugins/simple-plugin/Simple/RemovePlugin.hs b/testsuite/tests/plugins/simple-plugin/Simple/RemovePlugin.hs index 89464451ee..3867404d2c 100644 --- a/testsuite/tests/plugins/simple-plugin/Simple/RemovePlugin.hs +++ b/testsuite/tests/plugins/simple-plugin/Simple/RemovePlugin.hs @@ -17,6 +17,7 @@ import OccName import RdrName import Name import Avail +import GHC.Hs.Dump plugin :: Plugin plugin = defaultPlugin { parsedResultAction = parsedPlugin @@ -52,11 +53,13 @@ typecheckPlugin [name, "typecheck"] _ tc typecheckPlugin _ _ tc = return tc metaPlugin' :: [CommandLineOption] -> LHsExpr GhcTc -> TcM (LHsExpr GhcTc) -metaPlugin' opts (L l (HsPar x e)) = (\e' -> L l (HsPar x e')) <$> metaPlugin' opts e -metaPlugin' [name, "meta"] (L _ (HsApp noExt (L l (HsVar _ (L _ id))) e)) +metaPlugin' [name, "meta"] (L l (HsWrap ne w (HsPar x (L _ (HsApp noExt (L _ (HsVar _ (L _ id))) e))))) | occNameString (getOccName id) == name - = return e -metaPlugin' _ meta = return meta + = return (L l (HsWrap ne w (unLoc e))) +-- The test should always match this first case. If the desugaring changes +-- again in the future then the panic is more useful than the previous +-- inscrutable failure. +metaPlugin' _ meta = pprPanic "meta" (showAstData BlankSrcSpan meta) interfaceLoadPlugin' :: [CommandLineOption] -> ModIface -> IfM lcl ModIface interfaceLoadPlugin' [name, "interface"] iface |