diff --git a/hledger-lib/Hledger/Reports/MultiBalanceReports.hs b/hledger-lib/Hledger/Reports/MultiBalanceReports.hs index d2d545105..c9e7da23e 100644 --- a/hledger-lib/Hledger/Reports/MultiBalanceReports.hs +++ b/hledger-lib/Hledger/Reports/MultiBalanceReports.hs @@ -69,11 +69,11 @@ type MultiBalanceReportRow = (AccountName, AccountName, Int, [MixedAmount], M type MultiBalanceReportTotals = ([MixedAmount], MixedAmount, MixedAmount) -- (Totals list, sum of totals, average of totals) instance Show MultiBalanceReport where - -- use ppShow to break long lists onto multiple lines - -- we add some bogus extra shows here to help ppShow parse the output + -- use pshow (pretty-show's ppShow) to break long lists onto multiple lines + -- we add some bogus extra shows here to help it parse the output -- and wrap tuples and lists properly show (MultiBalanceReport (spans, items, totals)) = - "MultiBalanceReport (ignore extra quotes):\n" ++ ppShow (show spans, map show items, totals) + "MultiBalanceReport (ignore extra quotes):\n" ++ pshow (show spans, map show items, totals) -- type alias just to remind us which AccountNames might be depth-clipped, below. type ClippedAccountName = AccountName diff --git a/hledger-lib/Hledger/Utils/Debug.hs b/hledger-lib/Hledger/Utils/Debug.hs index 27ca08f67..2473cc835 100644 --- a/hledger-lib/Hledger/Utils/Debug.hs +++ b/hledger-lib/Hledger/Utils/Debug.hs @@ -8,9 +8,8 @@ -- http://hackage.haskell.org/packages/archive/traced/2009.7.20/doc/html/Debug-Traced.html module Hledger.Utils.Debug ( - module Hledger.Utils.Debug + module Hledger.Utils.Debug ,module Debug.Trace - ,ppShow ) where @@ -26,10 +25,15 @@ import System.Exit import System.IO.Unsafe (unsafePerformIO) import Text.Megaparsec import Text.Printf -import Text.Show.Pretty (ppShow) +import Text.Show.Pretty (ppShow, pPrint) +-- | Easier alias for pretty-show's pPrint. pprint :: Show a => a -> IO () -pprint = putStrLn . ppShow +pprint = pPrint + +-- | Easier alias for pretty-show's ppShow. +pshow :: Show a => a -> String +pshow = ppShow -- | Trace (print to stderr) a showable value using a custom show function. traceWith :: (a -> String) -> a -> a