packages feed

hpack 0.1.0 → 0.1.1

raw patch · 3 files changed

+22/−14 lines, 3 files

Files

driver/Main.hs view
@@ -2,15 +2,29 @@  import           Prelude () import           Prelude.Compat-import           Control.Monad-import           Control.DeepSeq+import           Control.Monad.Compat import           Control.Exception import           System.IO.Error+import           Data.List.Compat+import           Data.Version (showVersion)+import           Control.DeepSeq +import           Paths_hpack (version) import           Run +header :: String+header = unlines [+    "-- This file has been generated from " ++ configFile ++ " by hpack version " ++ showVersion version ++ "."+  , "--"+  , "-- see: https://github.com/sol/hpack"+  , ""+  ]+ main :: IO () main = do   (name, new) <- run-  old <- force . either (const Nothing) Just <$> tryJust (guard . isDoesNotExistError) (readFile name)-  unless (old == Just new) (writeFile name new)+  old <- force . either (const Nothing) (Just . stripHeader) <$> tryJust (guard . isDoesNotExistError) (readFile name)+  unless (old == Just (lines new)) (writeFile name $ header ++ new)+  where+    stripHeader :: String -> [String]+    stripHeader = dropWhile null . dropWhile ("--" `isPrefixOf`) . lines
hpack.cabal view
@@ -3,10 +3,11 @@ -- see: https://github.com/sol/hpack  name:           hpack-version:        0.1.0+version:        0.1.1 synopsis:       An alternative format for Haskell packages homepage:       https://github.com/sol/hpack#readme bug-reports:    https://github.com/sol/hpack/issues+maintainer:     Simon Hengel <sol@typeful.net> license:        MIT license-file:   LICENSE build-type:     Simple
src/Run.hs view
@@ -1,6 +1,7 @@ {-# LANGUAGE QuasiQuotes, RecordWildCards #-} module Run (   run+, configFile -- exported for testing , renderPackage ) where@@ -10,9 +11,7 @@ import           Data.Maybe import           Data.List import           System.Exit.Compat-import           Data.Version (showVersion) -import           Paths_hpack (version) import           Util import           Config @@ -29,13 +28,7 @@       old <- tryReadFile cabalFile        let alignment = fromMaybe 16 (old >>= sniffAlignment)-          output = concat [-              "-- This file has been generated from " ++ configFile ++ " by hpack version " ++ showVersion version ++ ".\n"-            , "--\n"-            , "-- see: https://github.com/sol/hpack\n"-            , "\n"-            , renderPackage alignment (maybe [] extractFieldOrderHint old) package-            ]+          output = renderPackage alignment (maybe [] extractFieldOrderHint old) package       return (cabalFile, output)     Left err -> die err