mirror of
https://github.com/simonmichael/hledger.git
synced 2024-11-08 07:09:28 +03:00
lib: Debug: simplify pprint, export ppShow as pshow (api change)
This commit is contained in:
parent
f62e308c9c
commit
9d2e80aa2c
@ -69,11 +69,11 @@ type MultiBalanceReportRow = (AccountName, AccountName, Int, [MixedAmount], M
|
|||||||
type MultiBalanceReportTotals = ([MixedAmount], MixedAmount, MixedAmount) -- (Totals list, sum of totals, average of totals)
|
type MultiBalanceReportTotals = ([MixedAmount], MixedAmount, MixedAmount) -- (Totals list, sum of totals, average of totals)
|
||||||
|
|
||||||
instance Show MultiBalanceReport where
|
instance Show MultiBalanceReport where
|
||||||
-- use ppShow to break long lists onto multiple lines
|
-- use pshow (pretty-show's ppShow) to break long lists onto multiple lines
|
||||||
-- we add some bogus extra shows here to help ppShow parse the output
|
-- we add some bogus extra shows here to help it parse the output
|
||||||
-- and wrap tuples and lists properly
|
-- and wrap tuples and lists properly
|
||||||
show (MultiBalanceReport (spans, items, totals)) =
|
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 alias just to remind us which AccountNames might be depth-clipped, below.
|
||||||
type ClippedAccountName = AccountName
|
type ClippedAccountName = AccountName
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
module Hledger.Utils.Debug (
|
module Hledger.Utils.Debug (
|
||||||
module Hledger.Utils.Debug
|
module Hledger.Utils.Debug
|
||||||
,module Debug.Trace
|
,module Debug.Trace
|
||||||
,ppShow
|
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
|
|
||||||
@ -26,10 +25,15 @@ import System.Exit
|
|||||||
import System.IO.Unsafe (unsafePerformIO)
|
import System.IO.Unsafe (unsafePerformIO)
|
||||||
import Text.Megaparsec
|
import Text.Megaparsec
|
||||||
import Text.Printf
|
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 :: 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.
|
-- | Trace (print to stderr) a showable value using a custom show function.
|
||||||
traceWith :: (a -> String) -> a -> a
|
traceWith :: (a -> String) -> a -> a
|
||||||
|
Loading…
Reference in New Issue
Block a user