stylish-haskell 0.14.5.0 → 0.14.6.0
raw patch · 8 files changed
+54/−16 lines, 8 filesdep ~bytestringdep ~ghcdep ~ghc-lib-parser
Dependency ranges changed: bytestring, ghc, ghc-lib-parser, ghc-lib-parser-ex, text
Files
- CHANGELOG +6/−1
- lib/Language/Haskell/Stylish/Printer.hs +1/−1
- lib/Language/Haskell/Stylish/Step/Data.hs +2/−2
- lib/Language/Haskell/Stylish/Step/Imports.hs +2/−2
- lib/Language/Haskell/Stylish/Step/ModuleHeader.hs +10/−2
- stylish-haskell.cabal +8/−8
- tests/Language/Haskell/Stylish/Step/LanguagePragmas/Tests.hs +5/−0
- tests/Language/Haskell/Stylish/Step/ModuleHeader/Tests.hs +20/−0
CHANGELOG view
@@ -1,7 +1,12 @@ # CHANGELOG +- 0.14.6.0 (2024-01-19)+ * #471 Support GHC 9.8 (by Michael Peyton Jones)+ * #440 Fix dissappearing `DEPRECATED` pragma on module (by Lev Dvorkin)+ * #464 Fix compilation issue with GHC 9.4+ - 0.14.5.0 (2023-06-23)- * #459 Support GHC 9.6 (By Michael Peyton Jones)+ * #459 Support GHC 9.6 (by Michael Peyton Jones) * #445 Default `ghc-lib` flag to True (by amesgen) - 0.14.4.0 (2023-01-09)
lib/Language/Haskell/Stylish/Printer.hs view
@@ -239,7 +239,7 @@ putOutputable ltp GHC.HsQualTy {} -> putOutputable ltp- GHC.HsAppKindTy _ _ _ ->+ GHC.HsAppKindTy _ _ _ _ -> putOutputable ltp GHC.HsListTy _ _ -> putOutputable ltp
lib/Language/Haskell/Stylish/Step/Data.hs view
@@ -313,10 +313,10 @@ maybePutKindSig where- firstTvar :: Maybe (GHC.LHsTyVarBndr () GHC.GhcPs)+ firstTvar :: Maybe (GHC.LHsTyVarBndr (GHC.HsBndrVis GHC.GhcPs) GHC.GhcPs) firstTvar = listToMaybe $ GHC.hsq_explicit dataTypeVars - secondTvar :: Maybe (GHC.LHsTyVarBndr () GHC.GhcPs)+ secondTvar :: Maybe (GHC.LHsTyVarBndr (GHC.HsBndrVis GHC.GhcPs) GHC.GhcPs) secondTvar = listToMaybe . drop 1 $ GHC.hsq_explicit dataTypeVars maybePutKindSig :: Printer ()
lib/Language/Haskell/Stylish/Step/Imports.hs view
@@ -594,8 +594,8 @@ -------------------------------------------------------------------------------- stringLiteral :: GHC.StringLiteral -> String stringLiteral sl = case GHC.sl_st sl of- GHC.NoSourceText -> show . GHC.unpackFS $ GHC.sl_fs sl- GHC.SourceText s -> s+ GHC.NoSourceText -> GHC.unpackFS $ GHC.sl_fs sl+ GHC.SourceText s -> GHC.unpackFS $ s --------------------------------------------------------------------------------
lib/Language/Haskell/Stylish/Step/ModuleHeader.hs view
@@ -30,6 +30,7 @@ import Language.Haskell.Stylish.Step import qualified Language.Haskell.Stylish.Step.Imports as Imports import Language.Haskell.Stylish.Util (flagEnds)+import qualified GHC.Unit.Module.Warnings as GHC data Config = Config@@ -69,6 +70,8 @@ let modul = GHC.unLoc lmodul name = GHC.unLoc <$> GHC.hsmodName modul + deprecMsg = GHC.hsmodDeprecMessage $ GHC.hsmodExt modul+ startLine = fromMaybe 1 $ moduleLine <|> (fmap GHC.srcSpanStartLine . GHC.srcSpanToRealSrcSpan $ GHC.getLoc lmodul)@@ -106,7 +109,7 @@ printedModuleHeader = runPrinter_ (PrinterConfig maxCols) (printHeader- conf name exportGroups moduleComment whereComment)+ conf name deprecMsg exportGroups moduleComment whereComment) changes = Editor.changeLines (Editor.Block startLine endLine)@@ -119,15 +122,20 @@ printHeader :: Config -> Maybe GHC.ModuleName+ -> Maybe (GHC.LocatedP (GHC.WarningTxt GHC.GhcPs)) -> Maybe [CommentGroup (GHC.LIE GHC.GhcPs)] -> Maybe GHC.LEpaComment -- Comment attached to 'module' -> Maybe GHC.LEpaComment -- Comment attached to 'where' -> P ()-printHeader conf mbName mbExps mbModuleComment mbWhereComment = do+printHeader conf mbName mbDeprec mbExps mbModuleComment mbWhereComment = do forM_ mbName $ \name -> do putText "module" space putText (showOutputable name)++ forM_ mbDeprec \deprec -> do+ putText " "+ putText (showOutputable deprec) case mbExps of Nothing -> do
stylish-haskell.cabal view
@@ -1,6 +1,6 @@ Cabal-version: 2.4 Name: stylish-haskell-Version: 0.14.5.0+Version: 0.14.6.0 Synopsis: Haskell code prettifier Homepage: https://github.com/haskell/stylish-haskell License: BSD-3-Clause@@ -34,9 +34,9 @@ Default-language: Haskell2010 Build-depends:- aeson >= 0.6 && < 2.2,+ aeson >= 0.6 && < 2.3, base >= 4.8 && < 5,- bytestring >= 0.9 && < 0.12,+ bytestring >= 0.9 && < 0.13, Cabal >= 3.4 && < 4.0, containers >= 0.3 && < 0.7, directory >= 1.2.3 && < 1.4,@@ -45,7 +45,7 @@ mtl >= 2.0 && < 2.4, regex-tdfa >= 1.3 && < 1.4, syb >= 0.3 && < 0.8,- text >= 1.2 && < 2.1,+ text >= 1.2 && < 2.2, HsYAML-aeson >=0.2.0 && < 0.3, HsYAML >=0.2.0 && < 0.3, @@ -57,17 +57,17 @@ -- and we have a new enough GHC. Note that -- this will only work if the user's -- compiler is of the matching major version!- if impl(ghc >= 9.4.1) && (!flag(ghc-lib))+ if !flag(ghc-lib) && impl(ghc >= 9.8) && impl(ghc < 9.9) Build-depends:- ghc >= 9.6 && < 9.7,+ ghc >= 9.8 && < 9.9, ghc-boot, ghc-boot-th else Build-depends:- ghc-lib-parser >= 9.6 && < 9.7+ ghc-lib-parser >= 9.8 && < 9.9 Build-depends:- ghc-lib-parser-ex >= 9.6 && < 9.7+ ghc-lib-parser-ex >= 9.8 && < 9.9 Library Import: depends
tests/Language/Haskell/Stylish/Step/LanguagePragmas/Tests.hs view
@@ -61,10 +61,12 @@ (step (Just 80) Vertical True True lANG) [ "{-# LANGUAGE BangPatterns #-}" , "{-# LANGUAGE ViewPatterns #-}"+ , "module Main where" , "increment ((+ 1) -> x) = x" ] [ "{-# LANGUAGE ViewPatterns #-}"+ , "module Main where" , "increment ((+ 1) -> x) = x" ] @@ -75,10 +77,12 @@ (step (Just 80) Vertical True True lANG) [ "{-# LANGUAGE BangPatterns #-}" , "{-# LANGUAGE ViewPatterns #-}"+ , "module Main where" , "increment x = case x of !_ -> x + 1" ] [ "{-# LANGUAGE BangPatterns #-}"+ , "module Main where" , "increment x = case x of !_ -> x + 1" ] @@ -226,6 +230,7 @@ input = [ "{-# LANGUAGE BangPatterns #-}" , "{-# LANGUAGE DeriveFunctor #-}"+ , "" , "main = let !x = 1 + 1 in print x" ]
tests/Language/Haskell/Stylish/Step/ModuleHeader/Tests.hs view
@@ -81,6 +81,8 @@ , testCase "Single one export with comment, open_bracket = same_line" ex31a , testCase "Single one module comment" ex32 , testCase "Inline comments" ex33+ , testCase "Deprecated pragma to the module" ex34+ , testCase "Warning pragma without export list" ex35 ] --------------------------------------------------------------------------------@@ -910,6 +912,24 @@ , " , foo -- Inline foo" , " ) where" ]++ex34 :: Assertion+ex34 = assertSnippet (step Nothing defaultConfig)+ [ "module X {-# DEPRECATED \"Do not use this\" #-}"+ , " (foo) where"+ ]+ [ "module X {-# DEPRECATED \"Do not use this\" #-}"+ , " ( foo"+ , " ) where"+ ]++ex35 :: Assertion+ex35 = assertSnippet (step Nothing defaultConfig) inp inp+ where inp = [ "module X {-# WARNING \"don't use it\" #-} where"+ , ""+ , "foo :: Int -> Int"+ , "foo = undefined"+ ] openBracketSameLine :: Config -> Config openBracketSameLine cfg = cfg { openBracket = SameLine }