From 71032c637ea4a449ec6983721ebdcc7eeac674f5 Mon Sep 17 00:00:00 2001 From: Stephen Morgan Date: Mon, 16 Aug 2021 15:38:25 +1000 Subject: [PATCH] cln: hlint: Remove cons warnings. --- .hlint.yaml | 1 - hledger-lib/Hledger/Data/Journal.hs | 3 +- hledger/Hledger/Cli/CliOptions.hs | 6 +-- hledger/Hledger/Cli/Commands/Close.hs | 39 +++++++++---------- hledger/Hledger/Cli/CompoundBalanceCommand.hs | 14 +++---- 5 files changed, 28 insertions(+), 35 deletions(-) diff --git a/.hlint.yaml b/.hlint.yaml index 26e8c39a1..83a96aa65 100644 --- a/.hlint.yaml +++ b/.hlint.yaml @@ -21,7 +21,6 @@ - ignore: {name: "Use unless"} - ignore: {name: "Use any"} - ignore: {name: "Use /="} -- ignore: {name: "Use :"} - ignore: {name: "Use =<<"} - ignore: {name: "Use fmap"} - ignore: {name: "Use curry"} diff --git a/hledger-lib/Hledger/Data/Journal.hs b/hledger-lib/Hledger/Data/Journal.hs index 7f5d832f8..ecfa131e4 100644 --- a/hledger-lib/Hledger/Data/Journal.hs +++ b/hledger-lib/Hledger/Data/Journal.hs @@ -400,8 +400,7 @@ journalAccountTypeQuery atypes fallbackregex Journal{jdeclaredaccounttypes} = concat $ mapMaybe (`M.lookup` jdeclaredaccounttypes) atypes in case declaredacctsoftype of [] -> Acct fallbackregex - as -> And $ [ Or acctnameRegexes ] - ++ if null differentlyTypedRegexes then [] else [ Not $ Or differentlyTypedRegexes ] + as -> And $ Or acctnameRegexes : if null differentlyTypedRegexes then [] else [ Not $ Or differentlyTypedRegexes ] where -- XXX Query isn't able to match account type since that requires extra info from the journal. -- So we do a hacky search by name instead. diff --git a/hledger/Hledger/Cli/CliOptions.hs b/hledger/Hledger/Cli/CliOptions.hs index 46d0d5124..dad23f3de 100644 --- a/hledger/Hledger/Cli/CliOptions.hs +++ b/hledger/Hledger/Cli/CliOptions.hs @@ -576,11 +576,7 @@ defaultOutputFormat :: String defaultOutputFormat = "txt" outputFormats :: [String] -outputFormats = - [defaultOutputFormat] ++ - ["csv" - ,"html" - ] +outputFormats = [defaultOutputFormat, "csv", "html"] -- | Get the output format from the --output-format option, -- otherwise from a recognised file extension in the --output-file option, diff --git a/hledger/Hledger/Cli/Commands/Close.hs b/hledger/Hledger/Cli/Commands/Close.hs index 6dae4bfde..da36032f4 100755 --- a/hledger/Hledger/Cli/Commands/Close.hs +++ b/hledger/Hledger/Cli/Commands/Close.hs @@ -119,18 +119,18 @@ close CliOpts{rawopts_=rawopts, reportspec_=rspec} j = do closingtxn = nulltransaction{tdate=closingdate, tdescription=closingdesc, tpostings=closingps} closingps = concat [ - [posting{paccount = a - ,pamount = mixedAmount . precise $ negate b - -- after each commodity's last posting, assert 0 balance (#1035) - -- balance assertion amounts are unpriced (#824) - ,pbalanceassertion = - if islast - then Just nullassertion{baamount=precise b{aquantity=0, aprice=Nothing}} - else Nothing - } - ] + posting{paccount = a + ,pamount = mixedAmount . precise $ negate b + -- after each commodity's last posting, assert 0 balance (#1035) + -- balance assertion amounts are unpriced (#824) + ,pbalanceassertion = + if islast + then Just nullassertion{baamount=precise b{aquantity=0, aprice=Nothing}} + else Nothing + } + -- maybe an interleaved posting transferring this balance to equity - ++ [posting{paccount=closingacct, pamount=mixedAmount $ precise b} | interleaved] + : [posting{paccount=closingacct, pamount=mixedAmount $ precise b} | interleaved] | -- get the balances for each commodity and transaction price (a,mb) <- acctbals @@ -149,15 +149,14 @@ close CliOpts{rawopts_=rawopts, reportspec_=rspec} j = do openingtxn = nulltransaction{tdate=openingdate, tdescription=openingdesc, tpostings=openingps} openingps = concat [ - [posting{paccount = a - ,pamount = mixedAmount $ precise b - ,pbalanceassertion = - case mcommoditysum of - Just s -> Just nullassertion{baamount=precise s{aprice=Nothing}} - Nothing -> Nothing - } - ] - ++ [posting{paccount=openingacct, pamount=mixedAmount . precise $ negate b} | interleaved] + posting{paccount = a + ,pamount = mixedAmount $ precise b + ,pbalanceassertion = + case mcommoditysum of + Just s -> Just nullassertion{baamount=precise s{aprice=Nothing}} + Nothing -> Nothing + } + : [posting{paccount=openingacct, pamount=mixedAmount . precise $ negate b} | interleaved] | (a,mb) <- acctbals , let bs = amounts $ normaliseMixedAmount mb diff --git a/hledger/Hledger/Cli/CompoundBalanceCommand.hs b/hledger/Hledger/Cli/CompoundBalanceCommand.hs index 6a877a475..4d5a28b22 100644 --- a/hledger/Hledger/Cli/CompoundBalanceCommand.hs +++ b/hledger/Hledger/Cli/CompoundBalanceCommand.hs @@ -278,13 +278,13 @@ compoundBalanceReportAsHtml ropts cbr = blankrow = tr_ $ td_ [colspanattr] $ toHtmlRaw (" "::String) titlerows = - [tr_ $ th_ [colspanattr, leftattr] $ h2_ $ toHtml title] - ++ [thRow $ - "" : ["Commodity" | commodity_column_ ropts] ++ - map (reportPeriodName (balanceaccum_ ropts) colspans) colspans - ++ (if row_total_ ropts then ["Total"] else []) - ++ (if average_ ropts then ["Average"] else []) - ] + (tr_ $ th_ [colspanattr, leftattr] $ h2_ $ toHtml title) + : [thRow $ + "" : ["Commodity" | commodity_column_ ropts] ++ + map (reportPeriodName (balanceaccum_ ropts) colspans) colspans + ++ (if row_total_ ropts then ["Total"] else []) + ++ (if average_ ropts then ["Average"] else []) + ] thRow :: [T.Text] -> Html () thRow = tr_ . mconcat . map (th_ . toHtml)