stylish-haskell 0.5.5.2 → 0.5.6.0
raw patch · 3 files changed
+18/−5 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- src/Language/Haskell/Stylish/Parse.hs +7/−4
- stylish-haskell.cabal +1/−1
- tests/Language/Haskell/Stylish/Parse/Tests.hs +10/−0
src/Language/Haskell/Stylish/Parse.hs view
@@ -6,7 +6,7 @@ -------------------------------------------------------------------------------- import Control.Monad.Error (throwError)-import Data.Maybe (fromMaybe)+import Data.Maybe (fromMaybe, listToMaybe) import qualified Language.Haskell.Exts.Annotated as H @@ -18,10 +18,13 @@ -------------------------------------------------------------------------------- -- | Filter out lines which use CPP macros unCpp :: String -> String-unCpp = unlines . map unCpp' . lines+unCpp = unlines . go False . lines where- unCpp' ('#' : _) = ""- unCpp' xs = xs+ go _ [] = []+ go isMultiline (x : xs) =+ let isCpp = isMultiline || listToMaybe x == Just '#'+ nextMultiline = isCpp && not (null x) && last x == '\\'+ in (if isCpp then "" else x) : go nextMultiline xs --------------------------------------------------------------------------------
stylish-haskell.cabal view
@@ -1,5 +1,5 @@ Name: stylish-haskell-Version: 0.5.5.2+Version: 0.5.6.0 Synopsis: Haskell code prettifier Homepage: https://github.com/jaspervdj/stylish-haskell License: BSD3
tests/Language/Haskell/Stylish/Parse/Tests.hs view
@@ -19,6 +19,7 @@ tests = testGroup "Language.Haskell.Stylish.Parse" [ testCase "UTF-8 Byte Order Mark" testBom , testCase "Extra extensions" testExtraExtensions+ , testCase "Multiline CPP" testMultilineCpp ] @@ -36,6 +37,15 @@ testExtraExtensions :: Assertion testExtraExtensions = assert $ isRight $ parseModule ["TemplateHaskell"] Nothing "$(foo)"+++--------------------------------------------------------------------------------+testMultilineCpp :: Assertion+testMultilineCpp = assert $ isRight $ parseModule [] Nothing $ unlines+ [ "{-# LANGUAGE CPP #-}"+ , "#define foo bar \\"+ , " qux"+ ] --------------------------------------------------------------------------------