stylish-haskell 0.5.11.2 → 0.5.12.0
raw patch · 4 files changed
+25/−3 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG +3/−0
- src/Language/Haskell/Stylish/Parse.hs +11/−2
- stylish-haskell.cabal +1/−1
- tests/Language/Haskell/Stylish/Parse/Tests.hs +10/−0
CHANGELOG view
@@ -1,3 +1,6 @@+- 0.5.12.0+ * Add support for shebang at start of file+ - 0.5.11.2 * Bump `filepath` dependency to 1.5
src/Language/Haskell/Stylish/Parse.hs view
@@ -7,6 +7,7 @@ -------------------------------------------------------------------------------- import Data.Maybe (fromMaybe, listToMaybe) import qualified Language.Haskell.Exts.Annotated as H+import Data.List (isPrefixOf) --------------------------------------------------------------------------------@@ -27,6 +28,14 @@ --------------------------------------------------------------------------------+-- | Remove shebang from the first line+unShebang :: String -> String+unShebang str+ | "#!" `isPrefixOf` str = unlines $ drop 1 $ lines str+ | otherwise = str+++-------------------------------------------------------------------------------- -- | If the given string is prefixed with an UTF-8 Byte Order Mark, drop it -- because haskell-src-exts can't handle it. dropBom :: String -> String@@ -55,10 +64,10 @@ } -- Preprocessing- noCpp =+ processed = unShebang $ if H.EnableExtension H.CPP `elem` exts then unCpp noBom else noBom - case H.parseModuleWithComments mode noCpp of+ case H.parseModuleWithComments mode processed of H.ParseOk md -> return md err -> Left $ "Language.Haskell.Stylish.Parse.parseModule: could not parse " ++
stylish-haskell.cabal view
@@ -1,5 +1,5 @@ Name: stylish-haskell-Version: 0.5.11.2+Version: 0.5.12.0 Synopsis: Haskell code prettifier Homepage: https://github.com/jaspervdj/stylish-haskell License: BSD3
tests/Language/Haskell/Stylish/Parse/Tests.hs view
@@ -21,6 +21,7 @@ , testCase "Extra extensions" testExtraExtensions , testCase "Multiline CPP" testMultilineCpp , testCase "Haskell2010 extension" testHaskell2010+ , testCase "Shebang" testShebang ] @@ -55,6 +56,15 @@ [ "{-# LANGUAGE Haskell2010 #-}" , "module X where" , "foo x | Just y <- x = y"+ ]+++--------------------------------------------------------------------------------+testShebang :: Assertion+testShebang = assert $ isRight $ parseModule [] Nothing $ unlines+ [ "#!runhaskell"+ , "module Main where"+ , "main = return ()" ]