diff --git a/CHANGES.md b/CHANGES.md index c830fce..ff773e0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,8 @@ Version 1.17 [????.??.??] * Support GHC 9.10. * Add support namespace identifiers in fixity declarations. As part of these changes, the `DInfixD` data constructor now has a `NamespaceSpecifier` field. +* Add support for `SCC` declarations via the new `DSCCP` data constructor for + the `DPragma` data type. * `extractBoundNamesDPat` no longer extracts type variables from constructor patterns. That this function ever did extract type variables was a mistake, and the new behavior of `extractBoundNamesDPat` brings it in line with the diff --git a/Language/Haskell/TH/Desugar/AST.hs b/Language/Haskell/TH/Desugar/AST.hs index 4e54d58..fece4ec 100644 --- a/Language/Haskell/TH/Desugar/AST.hs +++ b/Language/Haskell/TH/Desugar/AST.hs @@ -297,6 +297,7 @@ data DPragma = DInlineP Name Inline RuleMatch Phases | DLineP Int String | DCompleteP [Name] (Maybe Name) | DOpaqueP Name + | DSCCP Name (Maybe String) deriving (Eq, Show, Data, Generic, Lift) -- | Corresponds to TH's @RuleBndr@ type. diff --git a/Language/Haskell/TH/Desugar/Core.hs b/Language/Haskell/TH/Desugar/Core.hs index 8c2c221..15f2f8e 100644 --- a/Language/Haskell/TH/Desugar/Core.hs +++ b/Language/Haskell/TH/Desugar/Core.hs @@ -1065,6 +1065,9 @@ dsPragma (CompleteP cls mty) = return $ DCompleteP cls mty #if __GLASGOW_HASKELL__ >= 903 dsPragma (OpaqueP n) = return $ DOpaqueP n #endif +#if __GLASGOW_HASKELL__ >= 909 +dsPragma (SCCP nm mstr) = return $ DSCCP nm mstr +#endif -- | Desugar a @RuleBndr@. dsRuleBndr :: DsMonad q => RuleBndr -> q DRuleBndr diff --git a/Language/Haskell/TH/Desugar/Sweeten.hs b/Language/Haskell/TH/Desugar/Sweeten.hs index 40264b9..a30f4ca 100644 --- a/Language/Haskell/TH/Desugar/Sweeten.hs +++ b/Language/Haskell/TH/Desugar/Sweeten.hs @@ -279,6 +279,11 @@ pragmaToTH (DOpaqueP n) = OpaqueP n #else pragmaToTH (DOpaqueP {}) = error "OPAQUE pragmas only supported in GHC 9.4+" #endif +#if __GLASGOW_HASKELL__ >= 909 +pragmaToTH (DSCCP nm mstr) = SCCP nm mstr +#else +pragmaToTH (DSCCP {}) = error "SCCP pragmas only supported in GHC 9.10+" +#endif ruleBndrToTH :: DRuleBndr -> RuleBndr ruleBndrToTH (DRuleVar n) = RuleVar n diff --git a/Test/Dec.hs b/Test/Dec.hs index 0447772..4168b1a 100644 --- a/Test/Dec.hs +++ b/Test/Dec.hs @@ -56,6 +56,7 @@ $(S.dectest19) #if __GLASGOW_HASKELL__ >= 909 $(S.dectest20) +$(S.dectest21) #endif $(fmap unqualify S.instance_test) diff --git a/Test/DsDec.hs b/Test/DsDec.hs index dbec759..405f757 100644 --- a/Test/DsDec.hs +++ b/Test/DsDec.hs @@ -81,6 +81,7 @@ $(dsDecSplice S.dectest19) #if __GLASGOW_HASKELL__ >= 909 $(dsDecSplice S.dectest20) +$(dsDecSplice S.dectest21) #endif $(do decs <- S.rec_sel_test diff --git a/Test/Splices.hs b/Test/Splices.hs index 495bf13..de881aa 100644 --- a/Test/Splices.hs +++ b/Test/Splices.hs @@ -553,6 +553,10 @@ dectest20 = [d| infixr 3 data !@# (!@#) = (&&) type family (!@#) :: Bool -> Bool -> Bool |] + +dectest21 = [d| {-# SCC dec21 "dec21" #-} + dec21 :: a -> a + dec21 x = x |] #endif instance_test = [d| instance (Show a, Show b) => Show (a -> b) where