From 3431b1b0d92ff53b8f9a471e9991b6e9102b1a39 Mon Sep 17 00:00:00 2001 From: Stephen Morgan Date: Mon, 16 Aug 2021 13:43:28 +1000 Subject: [PATCH] cln: hlint: Clean up map-fusion related hlint warnings. --- .hlint.yaml | 4 ---- hledger-lib/Hledger/Data/Journal.hs | 2 +- hledger/Hledger/Cli/Commands/Prices.hs | 2 +- hledger/Hledger/Cli/Commands/Rewrite.hs | 2 +- hledger/Hledger/Cli/Utils.hs | 2 +- 5 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.hlint.yaml b/.hlint.yaml index 751da7d99..b81fc9076 100644 --- a/.hlint.yaml +++ b/.hlint.yaml @@ -34,15 +34,11 @@ - ignore: {name: "Redundant <$>"} - ignore: {name: "Use list literal pattern"} - ignore: {name: "Use fewer imports"} -- ignore: {name: "Use mapMaybe"} - ignore: {name: "Use intercalate"} - ignore: {name: "Use tuple-section"} - ignore: {name: "Use section"} - ignore: {name: "Use maybe"} -- ignore: {name: "Fuse concatMap/map"} -- ignore: {name: "Use concatMap"} - ignore: {name: "Redundant bang pattern"} -- ignore: {name: "Use zipWith"} - ignore: {name: "Replace case with maybe"} - ignore: {name: "Avoid lambda using `infix`"} - ignore: {name: "Use zip"} diff --git a/hledger-lib/Hledger/Data/Journal.hs b/hledger-lib/Hledger/Data/Journal.hs index ecfa131e4..0fab04a69 100644 --- a/hledger-lib/Hledger/Data/Journal.hs +++ b/hledger-lib/Hledger/Data/Journal.hs @@ -699,7 +699,7 @@ journalNumberAndTieTransactions = journalTieTransactions . journalNumberTransact -- | Number (set the tindex field) this journal's transactions, counting upward from 1. journalNumberTransactions :: Journal -> Journal -journalNumberTransactions j@Journal{jtxns=ts} = j{jtxns=map (\(i,t) -> t{tindex=i}) $ zip [1..] ts} +journalNumberTransactions j@Journal{jtxns=ts} = j{jtxns=zipWith (\i t -> t{tindex=i}) [1..] ts} -- | Tie the knot in all of this journal's transactions, ensuring their postings -- refer to them. This should be done last, after any other transaction-modifying operations. diff --git a/hledger/Hledger/Cli/Commands/Prices.hs b/hledger/Hledger/Cli/Commands/Prices.hs index 4f02b9cd7..7a9609120 100755 --- a/hledger/Hledger/Cli/Commands/Prices.hs +++ b/hledger/Hledger/Cli/Commands/Prices.hs @@ -33,7 +33,7 @@ prices opts j = do ps = filter (matchesPosting q) $ allPostings j mprices = jpricedirectives j cprices = map (stylePriceDirectiveExceptPrecision styles) $ concatMap postingsPriceDirectivesFromCosts ps - icprices = map (stylePriceDirectiveExceptPrecision styles) $ concatMap postingsPriceDirectivesFromCosts $ map (postingTransformAmount $ mapMixedAmount invertPrice) ps + icprices = map (stylePriceDirectiveExceptPrecision styles) $ concatMap (postingsPriceDirectivesFromCosts . postingTransformAmount (mapMixedAmount invertPrice)) ps allprices = mprices ++ ifBoolOpt "costs" cprices ++ ifBoolOpt "inverted-costs" icprices mapM_ (T.putStrLn . showPriceDirective) $ sortOn pddate $ diff --git a/hledger/Hledger/Cli/Commands/Rewrite.hs b/hledger/Hledger/Cli/Commands/Rewrite.hs index daaacd800..4213acf4c 100755 --- a/hledger/Hledger/Cli/Commands/Rewrite.hs +++ b/hledger/Hledger/Cli/Commands/Rewrite.hs @@ -126,7 +126,7 @@ diffTxn j t t' = -- original file, other adds transaction to new file with -- suffix .ledger (generated). I.e. move transaction from one file to another. diffs :: [DiffLine Text] - diffs = concat . map (traverse showPostingLines . mapDiff) $ D.getDiff (tpostings t) (tpostings t') + diffs = concatMap (traverse showPostingLines . mapDiff) $ D.getDiff (tpostings t) (tpostings t') pos@(JournalSourcePos fp (line, line')) -> (pos, diffs) where -- We do diff for original lines vs generated ones. Often leads -- to big diff because of re-format effect. diff --git a/hledger/Hledger/Cli/Utils.hs b/hledger/Hledger/Cli/Utils.hs index 12ec27df1..7cfa8fdbb 100644 --- a/hledger/Hledger/Cli/Utils.hs +++ b/hledger/Hledger/Cli/Utils.hs @@ -229,7 +229,7 @@ backUpFile :: FilePath -> IO () backUpFile fp = do fs <- safeGetDirectoryContents $ takeDirectory $ fp let (d,f) = splitFileName fp - versions = catMaybes $ map (f `backupNumber`) fs + versions = mapMaybe (f `backupNumber`) fs next = maximum (0:versions) + 1 f' = printf "%s.%d" f next copyFile fp (d f')