From f46360ed7139ff25741b381647b0a0b6d1000d84 Mon Sep 17 00:00:00 2001 From: Simon Peyton Jones Date: Tue, 10 Feb 2015 14:09:12 +0000 Subject: Refactor the handling of quasi-quotes As Trac #10047 points out, a quasi-quotation [n|...blah...|] is supposed to behave exactly like $(n "...blah..."). But it doesn't! This was outright wrong: quasiquotes were being run even inside brackets. Now that TH supports both typed and untyped splices, a quasi-quote is properly regarded as a particular syntax for an untyped splice. But apart from that they should be treated the same. So this patch refactors the handling of quasiquotes to do just that. The changes touch quite a lot of files, but mostly in a routine way. The biggest changes by far are in RnSplice, and more minor changes in TcSplice. These are the places where there was real work to be done. Everything else is routine knock-on changes. * No more QuasiQuote forms in declarations, expressions, types, etc. So we get rid of these data constructors * HsBinds.QuasiQuoteD * HsExpr.HsSpliceE * HsPat.QuasiQuotePat * HsType.HsQuasiQuoteTy * We get rid of the HsQuasiQuote type altogether * Instead, we augment the HsExpr.HsSplice type to have three consructors, for the three types of splice: * HsTypedSplice * HsUntypedSplice * HsQuasiQuote There are some related changes in the data types in HsExpr near HsSplice. Specifically: PendingRnSplice, PendingTcSplice, UntypedSpliceFlavour. * In Hooks, we combine rnQuasiQuoteHook and rnRnSpliceHook into one. A smaller, clearer interface. * We have to update the Haddock submodule, to accommodate the hsSyn changes --- compiler/main/Hooks.hs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'compiler/main') diff --git a/compiler/main/Hooks.hs b/compiler/main/Hooks.hs index fd25e330b4..f9339b1cef 100644 --- a/compiler/main/Hooks.hs +++ b/compiler/main/Hooks.hs @@ -20,13 +20,11 @@ module Hooks ( Hooks , runPhaseHook , runMetaHook , linkHook - , runQuasiQuoteHook , runRnSpliceHook , getValueSafelyHook ) where import DynFlags -import HsTypes import Name import PipelineMonad import HscTypes @@ -58,7 +56,7 @@ import Data.Maybe -- uses the default built-in behaviour emptyHooks :: Hooks -emptyHooks = Hooks Nothing Nothing Nothing Nothing Nothing Nothing +emptyHooks = Hooks Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing @@ -73,8 +71,7 @@ data Hooks = Hooks , runPhaseHook :: Maybe (PhasePlus -> FilePath -> DynFlags -> CompPipeline (PhasePlus, FilePath)) , runMetaHook :: Maybe (MetaHook TcM) , linkHook :: Maybe (GhcLink -> DynFlags -> Bool -> HomePackageTable -> IO SuccessFlag) - , runQuasiQuoteHook :: Maybe (HsQuasiQuote Name -> RnM (HsQuasiQuote Name)) - , runRnSpliceHook :: Maybe (LHsExpr Name -> RnM (LHsExpr Name)) + , runRnSpliceHook :: Maybe (HsSplice Name -> RnM (HsSplice Name)) , getValueSafelyHook :: Maybe (HscEnv -> Name -> Type -> IO (Maybe HValue)) } -- cgit v1.2.1