packages feed

stylish-haskell 0.2.0.2 → 0.3.0.0

raw patch · 7 files changed

+36/−23 lines, 7 filesdep +strict

Dependencies added: strict

Files

src/Main.hs view
@@ -8,9 +8,10 @@ -------------------------------------------------------------------------------- import           Control.Monad          (forM_) import           Data.List              (intercalate)-import           Data.Maybe             (listToMaybe) import           Data.Version           (Version(..))+import           Prelude                hiding (readFile) import           System.Console.CmdArgs+import           System.IO.Strict       (readFile)   --------------------------------------------------------------------------------@@ -26,6 +27,7 @@     { config   :: Maybe FilePath     , verbose  :: Bool     , defaults :: Bool+    , inPlace  :: Bool     , files    :: [FilePath]     } deriving (Data, Show, Typeable) @@ -36,6 +38,7 @@     { config   = Nothing &= typFile &= help "Configuration file"     , verbose  = False              &= help "Run in verbose mode"     , defaults = False              &= help "Dump default config and exit"+    , inPlace  = False              &= help "Overwrite the given files in place"     , files    = []      &= typFile &= args     } &= summary ("stylish-haskell-" ++ versionString version)   where@@ -58,8 +61,17 @@         conf <- loadConfig verbose' (config sa)         let steps = configSteps conf         forM_ steps $ \s -> verbose' $ "Enabled " ++ stepName s ++ " step"-        contents <- maybe getContents readFile filePath-        putStr $ unlines $ runSteps filePath steps $ lines contents+        mapM_ (file sa conf) files'   where     verbose' = makeVerbose (verbose sa)-    filePath = listToMaybe $ files sa+    files'   = if null (files sa) then [Nothing] else map Just (files sa)+++--------------------------------------------------------------------------------+-- | Processes a single file, or stdin if no filepath is given+file :: StylishArgs -> Config -> Maybe FilePath -> IO ()+file sa conf mfp = do+    contents <- maybe getContents readFile mfp+    write $ unlines $ runSteps mfp (configSteps conf) $ lines contents+  where+    write = maybe putStr (if inPlace sa then writeFile else const putStr) mfp
src/StylishHaskell/Step/TrailingWhitespace.hs view
@@ -5,7 +5,7 @@   ---------------------------------------------------------------------------------import           Data.Char            (isSpace)+import           Data.Char           (isSpace)   --------------------------------------------------------------------------------
src/StylishHaskell/Step/UnicodeSyntax.hs view
@@ -1,16 +1,15 @@ ---------------------------------------------------------------------------------{-# LANGUAGE ViewPatterns #-} module StylishHaskell.Step.UnicodeSyntax     ( step     ) where   ---------------------------------------------------------------------------------import           Data.List                              (isPrefixOf, sort)-import           Data.Map                               (Map)-import qualified Data.Map                               as M-import           Data.Maybe                             (maybeToList)-import qualified Language.Haskell.Exts.Annotated        as H+import           Data.List                           (isPrefixOf, sort)+import           Data.Map                            (Map)+import qualified Data.Map                            as M+import           Data.Maybe                          (maybeToList)+import qualified Language.Haskell.Exts.Annotated     as H   --------------------------------------------------------------------------------
stylish-haskell.cabal view
@@ -1,5 +1,5 @@ Name:          stylish-haskell-Version:       0.2.0.2+Version:       0.3.0.0 Synopsis:      Haskell code prettifier Homepage:      https://github.com/jaspervdj/stylish-haskell License:       BSD3@@ -52,7 +52,8 @@     filepath         >= 1.1  && < 1.4,     haskell-src-exts >= 1.13 && < 1.14,     syb              >= 0.3  && < 0.4,-    yaml             >= 0.7  && < 0.8+    yaml             >= 0.7  && < 0.8,+    strict           >= 0.3  && < 0.4  Test-suite stylish-haskell-tests   Ghc-options:    -Wall@@ -82,7 +83,8 @@     filepath         >= 1.1  && < 1.4,     haskell-src-exts >= 1.13 && < 1.14,     syb              >= 0.3  && < 0.4,-    yaml             >= 0.7  && < 0.8+    yaml             >= 0.7  && < 0.8,+    strict           >= 0.3  && < 0.4  Source-repository head   Type:     git
tests/StylishHaskell/Step/LanguagePragmas/Tests.hs view
@@ -5,9 +5,9 @@   ---------------------------------------------------------------------------------import           Test.Framework                 (Test, testGroup)-import           Test.Framework.Providers.HUnit (testCase)-import           Test.HUnit                     ((@=?))+import           Test.Framework                      (Test, testGroup)+import           Test.Framework.Providers.HUnit      (testCase)+import           Test.HUnit                          ((@=?))   --------------------------------------------------------------------------------
tests/StylishHaskell/Step/TrailingWhitespace/Tests.hs view
@@ -5,9 +5,9 @@   ---------------------------------------------------------------------------------import           Test.Framework                 (Test, testGroup)-import           Test.Framework.Providers.HUnit (testCase)-import           Test.HUnit                     ((@=?))+import           Test.Framework                         (Test, testGroup)+import           Test.Framework.Providers.HUnit         (testCase)+import           Test.HUnit                             ((@=?))   --------------------------------------------------------------------------------
tests/StylishHaskell/Step/UnicodeSyntax/Tests.hs view
@@ -5,9 +5,9 @@   ---------------------------------------------------------------------------------import           Test.Framework                 (Test, testGroup)-import           Test.Framework.Providers.HUnit (testCase)-import           Test.HUnit                     ((@=?))+import           Test.Framework                    (Test, testGroup)+import           Test.Framework.Providers.HUnit    (testCase)+import           Test.HUnit                        ((@=?))   --------------------------------------------------------------------------------