From 342bae8c3520d7f9e310461021fe2309bb1bb5ec Mon Sep 17 00:00:00 2001 From: Ryan Desfosses Date: Sun, 11 May 2014 19:27:39 -0400 Subject: [PATCH 1/2] Histogram: cabal test and hlint warnings --- hledger/Hledger/Cli/Histogram.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/hledger/Hledger/Cli/Histogram.hs b/hledger/Hledger/Cli/Histogram.hs index af88305b5..aebc36618 100644 --- a/hledger/Hledger/Cli/Histogram.hs +++ b/hledger/Hledger/Cli/Histogram.hs @@ -6,6 +6,7 @@ Print a histogram report. (The "activity" command). module Hledger.Cli.Histogram where + import Data.List import Data.Maybe import Data.Ord @@ -19,8 +20,8 @@ import Hledger.Query import Prelude hiding (putStr) import Hledger.Utils.UTF8IOCompat (putStr) - -activitymode = (defCommandMode $ ["activity"] ++ aliases) { +activitymode :: Mode RawOpts +activitymode = (defCommandMode $ ["activity"] : aliases) { modeHelp = "show an ascii barchart of posting counts per interval (default: daily)" `withAliases` aliases ,modeHelpSuffix = [] ,modeGroupFlags = Group { @@ -31,6 +32,7 @@ activitymode = (defCommandMode $ ["activity"] ++ aliases) { } where aliases = [] +barchar :: Char barchar = '*' -- | Print a histogram of some statistic per reporting interval, such as @@ -46,8 +48,8 @@ showHistogram opts q j = concatMap (printDayWith countBar) spanps i = intervalFromOpts opts interval | i == NoInterval = Days 1 | otherwise = i - span = queryDateSpan (date2_ opts) q `spanDefaultsFrom` journalDateSpan (date2_ opts) j - spans = filter (DateSpan Nothing Nothing /=) $ splitSpan interval span + span' = queryDateSpan (date2_ opts) q `spanDefaultsFrom` journalDateSpan (date2_ opts) j + spans = filter (DateSpan Nothing Nothing /=) $ splitSpan interval span' spanps = [(s, filter (isPostingInDateSpan s) ps) | s <- spans] -- same as Register -- should count transactions, not postings ? From 47853d6df6a0966f644b8039b5c4e7d6dcabf9a8 Mon Sep 17 00:00:00 2001 From: Ryan Desfosses Date: Sun, 11 May 2014 20:19:36 -0400 Subject: [PATCH 2/2] Cli: cabal test and hlint warnings --- hledger/Hledger/Cli.hs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/hledger/Hledger/Cli.hs b/hledger/Hledger/Cli.hs index 8f3f821ee..21fca23bc 100644 --- a/hledger/Hledger/Cli.hs +++ b/hledger/Hledger/Cli.hs @@ -97,8 +97,8 @@ tests_Hledger_Cli = TestList ,"account directive should preserve \"virtual\" posting type" ~: do j <- readJournal Nothing Nothing Nothing "!account test\n2008/12/07 One\n (from) $-1\n (to) $1\n" >>= either error' return let p = head $ tpostings $ head $ jtxns j - assertBool "" $ (paccount p) == "test:from" - assertBool "" $ (ptype p) == VirtualPosting + assertBool "" $ paccount p == "test:from" + assertBool "" $ ptype p == VirtualPosting ] @@ -188,6 +188,7 @@ sample_journal_str = unlines ] -} +defaultyear_journal_str :: String defaultyear_journal_str = unlines ["Y2009" ,"" @@ -337,9 +338,10 @@ defaultyear_journal_str = unlines -- ,"" -- ] +journal7 :: Journal journal7 = nulljournal {jtxns = [ - txnTieKnot $ Transaction { + txnTieKnot Transaction { tdate=parsedate "2007/01/01", tdate2=Nothing, tstatus=False, @@ -354,7 +356,7 @@ journal7 = nulljournal {jtxns = tpreceding_comment_lines="" } , - txnTieKnot $ Transaction { + txnTieKnot Transaction { tdate=parsedate "2007/02/01", tdate2=Nothing, tstatus=False, @@ -369,7 +371,7 @@ journal7 = nulljournal {jtxns = tpreceding_comment_lines="" } , - txnTieKnot $ Transaction { + txnTieKnot Transaction { tdate=parsedate "2007/01/02", tdate2=Nothing, tstatus=False, @@ -384,7 +386,7 @@ journal7 = nulljournal {jtxns = tpreceding_comment_lines="" } , - txnTieKnot $ Transaction { + txnTieKnot Transaction { tdate=parsedate "2007/01/03", tdate2=Nothing, tstatus=False, @@ -399,7 +401,7 @@ journal7 = nulljournal {jtxns = tpreceding_comment_lines="" } , - txnTieKnot $ Transaction { + txnTieKnot Transaction { tdate=parsedate "2007/01/03", tdate2=Nothing, tstatus=False, @@ -414,7 +416,7 @@ journal7 = nulljournal {jtxns = tpreceding_comment_lines="" } , - txnTieKnot $ Transaction { + txnTieKnot Transaction { tdate=parsedate "2007/01/03", tdate2=Nothing, tstatus=False, @@ -431,4 +433,5 @@ journal7 = nulljournal {jtxns = ] } +ledger7 :: Ledger ledger7 = ledgerFromJournal Any journal7