auto-split 0.1.0.5 → 0.1.1.0
raw patch · 6 files changed
+38/−68 lines, 6 filesdep ~ghcdep ~ghc-exactprintPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: ghc, ghc-exactprint
API changes (from Hackage documentation)
Files
- CHANGELOG.md +5/−0
- auto-split.cabal +4/−4
- src/AutoSplit.hs +0/−27
- src/AutoSplit/GhcFacade.hs +21/−33
- src/AutoSplit/Shared.hs +1/−1
- src/AutoSplit/Split.hs +7/−3
CHANGELOG.md view
@@ -1,5 +1,10 @@ # Revision history for auto-split +## 0.1.1.0 -- 2026-05-13++* Support GHC 9.14+* Drop support for 9.6+ ## 0.1.0.5 -- 2025-09-07 * Fix a bug with out of scope constructors
auto-split.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: auto-split-version: 0.1.0.5+version: 0.1.1.0 synopsis: Case splitting plugin description: A GHC plugin that performs automatic case splitting license: BSD-3-Clause@@ -12,7 +12,7 @@ extra-doc-files: CHANGELOG.md README.md-tested-with: GHC == 9.12.1, GHC == 9.10.1, GHC == 9.8.2, GHC == 9.6.6+tested-with: GHC == 9.14.1, GHC == 9.12.1, GHC == 9.10.1, GHC == 9.8.2 source-repository head type: git@@ -31,9 +31,9 @@ AutoSplit.Split -- other-extensions: build-depends: base <5,- ghc >=9.6 && <9.13,+ ghc >=9.8 && <9.15, syb <0.8,- ghc-exactprint <1.13,+ ghc-exactprint <1.15, ghc-paths <0.2, transformers <0.7 hs-source-dirs: src
src/AutoSplit.hs view
@@ -219,9 +219,6 @@ diagnosticReason _ = Ghc.ErrorWithoutFlag diagnosticHints _ = [] diagnosticCode _ = Nothing-#if !MIN_VERSION_ghc(9,8,0)- defaultDiagnosticOpts = Ghc.NoDiagnosticOpts-#endif -- | Diagnostic thrown when SPLIT is used but there are no resulting warnings data NoMissingPat = NoMissingPat@@ -233,9 +230,6 @@ diagnosticReason _ = Ghc.ErrorWithoutFlag diagnosticHints _ = [] diagnosticCode _ = Nothing-#if !MIN_VERSION_ghc(9,8,0)- defaultDiagnosticOpts = Ghc.NoDiagnosticOpts-#endif -- | Diagnostic thrown when SPLIT is used but there are no resulting warnings data ImproperUse = ImproperUse@@ -247,9 +241,6 @@ diagnosticReason _ = Ghc.ErrorWithoutFlag diagnosticHints _ = [] diagnosticCode _ = Nothing-#if !MIN_VERSION_ghc(9,8,0)- defaultDiagnosticOpts = Ghc.NoDiagnosticOpts-#endif -- | Diagnostic thrown if the module fails to parse data ParseFailed = ParseFailed@@ -261,9 +252,6 @@ diagnosticReason _ = Ghc.ErrorWithoutFlag diagnosticHints _ = [] diagnosticCode _ = Nothing-#if !MIN_VERSION_ghc(9,8,0)- defaultDiagnosticOpts = Ghc.NoDiagnosticOpts-#endif -- | Adds the import for SPLIT to the module being compiled. Otherwise users -- would have to manually add this import everytime they want to do pattern splitting.@@ -287,7 +275,6 @@ removeUnusedImportWarn :: Ghc.TcM () removeUnusedImportWarn = do errsVar <- Ghc.getErrsVar-#if MIN_VERSION_ghc(9,8,0) let isAutoSplitImportWarn msgEnv = case Ghc.errMsgDiagnostic msgEnv of Ghc.TcRnMessageWithInfo _ (Ghc.TcRnMessageDetailed _ (Ghc.TcRnUnusedImport decl _)) ->@@ -295,20 +282,6 @@ _ -> False Ghc.liftIO . modifyIORef errsVar $ Ghc.mkMessages . Ghc.filterBag (not . isAutoSplitImportWarn) . Ghc.getMessages-#else- -- 9.6 lacks the specific diagnostic- let isAutoSplitImportWarn msgEnv =- case Ghc.errMsgDiagnostic msgEnv of- Ghc.TcRnMessageWithInfo _ (Ghc.TcRnMessageDetailed _ (Ghc.TcRnUnknownMessage (Ghc.UnknownDiagnostic diag)))- | Ghc.WarningWithFlag Ghc.Opt_WarnUnusedImports <- Ghc.diagnosticReason diag- -> True- _ -> False- Ghc.liftIO . modifyIORef errsVar $ \msgs ->- -- the target import warning always shows up as the last occurrence- case break isAutoSplitImportWarn . reverse . Ghc.bagToList $ Ghc.getMessages msgs of- (before, _ : after) -> Ghc.mkMessages . Ghc.listToBag . reverse $ before ++ after- _ -> msgs-#endif patternModName :: IsString a => a patternModName = "AutoSplit.Pattern"
src/AutoSplit/GhcFacade.hs view
@@ -17,21 +17,14 @@ , fakeCommentLocation , parenAnns , parenHashAnns- , greToName , noLocCpp , noExtFieldCpp , equalsAnns , pattern UnknownDiagnostic' ) where -#if MIN_VERSION_ghc(9,8,0) import GHC.Driver.DynFlags as Ghc import GHC.Types.Var as Ghc-#else-import GHC.Driver.Flags as Ghc-import GHC.Types.Var as Ghc hiding (varName)-import GHC.Driver.Session as Ghc-#endif import GHC as Ghc (ParsedSource) import GHC.Core.ConLike as Ghc import GHC.Core.DataCon as Ghc@@ -45,6 +38,9 @@ import GHC.Driver.Plugins as Ghc import GHC.Driver.Monad as Ghc import GHC.Hs as Ghc+#if MIN_VERSION_ghc(9,14,0)+ hiding (HoleError)+#endif import GHC.HsToCore.Errors.Types as Ghc import GHC.HsToCore.Pmc.Solver.Types as Ghc import GHC.Tc.Errors.Types as Ghc@@ -71,7 +67,7 @@ mkParPat' :: Ghc.LPat Ghc.GhcPs -> Ghc.Pat Ghc.GhcPs #if MIN_VERSION_ghc(9,10,0) mkParPat' inner = Ghc.ParPat (Ghc.EpTok EP.d0, Ghc.EpTok EP.d0) inner-#elif MIN_VERSION_ghc(9,6,0)+#elif MIN_VERSION_ghc(9,8,0) mkParPat' inner = Ghc.ParPat Ghc.noAnn (Ghc.L (Ghc.TokenLoc EP.d0) Ghc.HsTok) inner (Ghc.L (Ghc.TokenLoc EP.d0) Ghc.HsTok) #endif @@ -79,7 +75,7 @@ #if MIN_VERSION_ghc(9,10,0) :: Ghc.NoAnn ann => Ghc.EpAnn ann anchorD0 = Ghc.EpAnn EP.d0 Ghc.noAnn Ghc.emptyComments-#elif MIN_VERSION_ghc(9,6,0)+#elif MIN_VERSION_ghc(9,8,0) :: Ghc.SrcSpanAnnA anchorD0 = Ghc.SrcSpanAnn@@ -95,7 +91,7 @@ #if MIN_VERSION_ghc(9,10,0) :: Ghc.NoAnn ann => Ghc.EpAnn ann anchorD1 = Ghc.EpAnn EP.d1 Ghc.noAnn Ghc.emptyComments-#elif MIN_VERSION_ghc(9,6,0)+#elif MIN_VERSION_ghc(9,8,0) :: Monoid ann => Ghc.SrcAnn ann -- blarg@@ -116,7 +112,7 @@ #if MIN_VERSION_ghc(9,10,0) :: Ghc.NoAnn ann => Ghc.EpAnn ann nameAnchorD0 = Ghc.EpAnn EP.d0 Ghc.noAnn Ghc.emptyComments-#elif MIN_VERSION_ghc(9,6,0)+#elif MIN_VERSION_ghc(9,8,0) :: Ghc.SrcSpanAnnN nameAnchorD0 = Ghc.SrcSpanAnn@@ -132,7 +128,7 @@ #if MIN_VERSION_ghc(9,10,0) :: Ghc.NoAnn ann => Ghc.EpAnn ann nameAnchorD1 = Ghc.EpAnn EP.d1 Ghc.noAnn Ghc.emptyComments-#elif MIN_VERSION_ghc(9,6,0)+#elif MIN_VERSION_ghc(9,8,0) :: Ghc.SrcSpanAnnN nameAnchorD1 = Ghc.SrcSpanAnn@@ -154,7 +150,7 @@ -> Ghc.NoAnn ann => Ghc.EpAnn ann nextLine colOffset = Ghc.EpAnn (Ghc.EpaDelta (Ghc.DifferentLine 1 colOffset) []) Ghc.noAnn Ghc.emptyComments-#elif MIN_VERSION_ghc(9,6,0)+#elif MIN_VERSION_ghc(9,8,0) -> Ghc.SrcSpanAnnA nextLine colOffset = Ghc.SrcSpanAnn@@ -172,7 +168,7 @@ #elif MIN_VERSION_ghc(9,10,0) colDelta :: Ghc.EpAnn ann -> Int colDelta (Ghc.EpAnn (Ghc.EpaDelta delta _) _ _)-#elif MIN_VERSION_ghc(9,6,0)+#elif MIN_VERSION_ghc(9,8,0) colDelta :: Ghc.SrcSpanAnn' (Ghc.EpAnn ann) -> Int colDelta (Ghc.SrcSpanAnn (Ghc.EpAnn (Ghc.Anchor _ (Ghc.MovedAnchor delta)) _ _) _) #endif@@ -184,7 +180,7 @@ #if MIN_VERSION_ghc(9,10,0) getComments :: Ghc.EpAnn ann -> Ghc.EpAnnComments getComments = Ghc.comments-#elif MIN_VERSION_ghc(9,6,0)+#elif MIN_VERSION_ghc(9,8,0) getComments :: Ghc.SrcSpanAnn' (Ghc.EpAnn ann) -> Ghc.EpAnnComments getComments a = case Ghc.ann a of Ghc.EpAnnNotUsed -> Ghc.emptyComments@@ -194,7 +190,7 @@ #if MIN_VERSION_ghc(9,10,0) setComments :: Ghc.EpAnnComments -> () -> Ghc.EpAnn ann -> Ghc.EpAnn ann setComments comms () a = a {Ghc.comments = comms}-#elif MIN_VERSION_ghc(9,6,0)+#elif MIN_VERSION_ghc(9,8,0) setComments :: Ghc.EpAnnComments -> ann -> Ghc.SrcSpanAnn' (Ghc.EpAnn ann) -> Ghc.SrcSpanAnn' (Ghc.EpAnn ann) setComments comms defAnn a = case Ghc.ann a of@@ -217,7 +213,7 @@ #elif MIN_VERSION_ghc(9,10,0) :: Ghc.NoCommentsLocation fakeCommentLocation = Ghc.EpaDelta (Ghc.DifferentLine (-1) 0) Ghc.NoComments-#elif MIN_VERSION_ghc(9,6,0)+#elif MIN_VERSION_ghc(9,8,0) :: Ghc.Anchor fakeCommentLocation = Ghc.Anchor Ghc.placeholderRealSpan (Ghc.MovedAnchor (Ghc.DifferentLine (-1) 0)) #endif@@ -228,7 +224,7 @@ #elif MIN_VERSION_ghc(9,10,0) equalsAnns :: [Ghc.AddEpAnn] equalsAnns = [Ghc.AddEpAnn Ghc.AnnEqual EP.d1]-#else+#elif MIN_VERSION_ghc(9,8,0) equalsAnns :: Ghc.EpAnn [Ghc.AddEpAnn] equalsAnns = Ghc.EpAnn { Ghc.entry = Ghc.Anchor Ghc.placeholderRealSpan EP.m0@@ -255,7 +251,7 @@ [ Ghc.AddEpAnn Ghc.AnnOpenPH EP.d0 , Ghc.AddEpAnn Ghc.AnnClosePH EP.d0 ]-#else+#elif MIN_VERSION_ghc(9,8,0) parenAnns :: Ghc.EpAnn [Ghc.AddEpAnn] parenAnns = Ghc.EpAnn { Ghc.entry = Ghc.Anchor Ghc.placeholderRealSpan EP.m0@@ -277,18 +273,10 @@ } #endif -greToName :: Ghc.GlobalRdrElt -> Ghc.Name-greToName =-#if MIN_VERSION_ghc(9,8,0)- Ghc.greName-#else- Ghc.grePrintableName-#endif- #if MIN_VERSION_ghc(9,12,0) noLocCpp :: Ghc.HasAnnotation e => a -> Ghc.GenLocated e a noLocCpp = Ghc.noLocA-#else+#elif MIN_VERSION_ghc(9,8,0) noLocCpp :: a -> a noLocCpp = id #endif@@ -299,7 +287,7 @@ #elif MIN_VERSION_ghc(9,10,0) noExtFieldCpp :: [a] noExtFieldCpp = []-#else+#elif MIN_VERSION_ghc(9,8,0) noExtFieldCpp :: Ghc.EpAnn a noExtFieldCpp = Ghc.noAnn #endif@@ -308,10 +296,10 @@ :: () => (Ghc.Diagnostic a, Typeable a) => a-#if MIN_VERSION_ghc(9,8,0)+#if MIN_VERSION_ghc(9,14,0)+ -> Ghc.UnknownDiagnostic opts hints+pattern UnknownDiagnostic' a <- Ghc.UnknownDiagnostic _ _ a+#elif MIN_VERSION_ghc(9,8,0) -> Ghc.UnknownDiagnostic opts pattern UnknownDiagnostic' a <- Ghc.UnknownDiagnostic _ a-#else- -> Ghc.UnknownDiagnostic-pattern UnknownDiagnostic' a <- Ghc.UnknownDiagnostic a #endif
@@ -61,7 +61,7 @@ Nothing -> Ghc.nameRdrName n -- built in thing that doesn't need to be imported where occName = Ghc.getOccName n- greMatches gre = Ghc.greToName gre == n+ greMatches gre = Ghc.greName gre == n addCommaAnns :: [Ghc.GenLocated Ghc.SrcSpanAnnA e] -> [Ghc.GenLocated Ghc.SrcSpanAnnA e] addCommaAnns [] = []
src/AutoSplit/Split.hs view
@@ -74,7 +74,7 @@ , Just caseLoc <- Ghc.srcSpanToRealSrcSpan $ Ghc.locA ann , Just neIdx <- List.findIndex ((caseLoc ==) . srcCodeLoc) nePats = Ghc.L (addIndexComment ann neIdx) l-#elif MIN_VERSION_ghc(9,6,0)+#elif MIN_VERSION_ghc(9,8,0) goExpr (Ghc.L ann l@(Ghc.HsLamCase _ _ _)) | Just caseLoc <- Ghc.srcSpanToRealSrcSpan $ Ghc.locA ann , Just neIdx <- List.findIndex ((caseLoc ==) . srcCodeLoc) nePats@@ -128,7 +128,7 @@ = ( Ghc.L ann {Ghc.comments = otherComms} (Ghc.HsLam x lamType newMG) , Any True )-#elif MIN_VERSION_ghc(9,6,0)+#elif MIN_VERSION_ghc(9,8,0) goExpr (Ghc.L ann (Ghc.HsLamCase x lamType matchGroup@(Ghc.MG _ (Ghc.L matchesAnn _)))) | Just (neIdx, otherComms) <- extractIdxComment (Ghc.getComments ann) , Just nePat <- listToMaybe $ drop neIdx nePats@@ -274,7 +274,11 @@ ( Ghc.L Ghc.nameAnchorD0 . nameToRdrName gblRdrEnv $ Ghc.conLikeName con )- $ Ghc.PrefixCon [] (mkPat gblRdrEnv nabla False True <$> args)+ $ Ghc.PrefixCon+#if !MIN_VERSION_ghc(9,14,0)+ []+#endif+ (mkPat gblRdrEnv nabla False True <$> args) Just (Ghc.PACA (Ghc.PmAltLit lit) _tvs _args) -> case Ghc.pm_lit_val lit of Ghc.PmLitInt integer ->