diff --git a/hledger-lib/Hledger/Data/Account.hs b/hledger-lib/Hledger/Data/Account.hs index dba055430..597d8a085 100644 --- a/hledger-lib/Hledger/Data/Account.hs +++ b/hledger-lib/Hledger/Data/Account.hs @@ -14,7 +14,6 @@ import Data.List.Extra (groupSort, groupOn) import Data.Maybe (fromMaybe) import Data.Ord (Down(..)) import qualified Data.Map as M -import qualified Data.Text as T import Safe (headMay, lookupJustDef) import Text.Printf @@ -28,12 +27,11 @@ import Hledger.Utils -- deriving instance Show Account instance Show Account where show Account{..} = printf "Account %s (boring:%s, postings:%d, ebalance:%s, ibalance:%s)" - (T.map colonToUnderscore aname) -- hide : so pretty-show doesn't break line + aname (if aboring then "y" else "n" :: String) anumpostings (showMixedAmount aebalance) (showMixedAmount aibalance) - where colonToUnderscore x = if x == ':' then '_' else x instance Eq Account where (==) a b = aname a == aname b -- quick equality test for speed diff --git a/hledger-lib/Hledger/Data/Dates.hs b/hledger-lib/Hledger/Data/Dates.hs index eda23109f..3ccdeae46 100644 --- a/hledger-lib/Hledger/Data/Dates.hs +++ b/hledger-lib/Hledger/Data/Dates.hs @@ -111,7 +111,6 @@ import Hledger.Utils -- Help ppShow parse and line-wrap DateSpans better in debug output. instance Show DateSpan where show s = "DateSpan " ++ showDateSpan s - -- show s = "DateSpan \"" ++ showDateSpan s ++ "\"" -- quotes to help pretty-show showDate :: Day -> String showDate = show diff --git a/hledger-lib/Hledger/Utils/Debug.hs b/hledger-lib/Hledger/Utils/Debug.hs index 1e208c645..d24f264cb 100644 --- a/hledger-lib/Hledger/Utils/Debug.hs +++ b/hledger-lib/Hledger/Utils/Debug.hs @@ -89,6 +89,7 @@ import Control.Monad (when) import Control.Monad.IO.Class import Data.List hiding (uncons) import qualified Data.Text as T +import qualified Data.Text.Lazy as TL import Debug.Trace import Hledger.Utils.Parse import Safe (readDef) @@ -97,17 +98,27 @@ import System.Exit import System.IO.Unsafe (unsafePerformIO) import Text.Megaparsec import Text.Printf -import Text.Show.Pretty (ppShow, pPrint) +import Text.Pretty.Simple -- (defaultOutputOptionsDarkBg, OutputOptions(..), pShowOpt, pPrintOpt) --- | Pretty print. Easier alias for pretty-show's pPrint. +prettyopts = + defaultOutputOptionsDarkBg + -- defaultOutputOptionsLightBg + -- defaultOutputOptionsNoColor + { outputOptionsIndentAmount=2 + , outputOptionsCompact=True + } + +-- | Pretty print. Generic alias for pretty-simple's pPrint. pprint :: Show a => a -> IO () -pprint = pPrint +pprint = pPrintOpt CheckColorTty prettyopts --- | Pretty show. Easier alias for pretty-show's ppShow. +-- | Pretty show. Generic alias for pretty-simple's pShow. pshow :: Show a => a -> String -pshow = ppShow +pshow = TL.unpack . pShowOpt prettyopts --- | Pretty trace. Easier alias for traceShowId + ppShow. +-- XXX some of the below can be improved with pretty-simple, https://github.com/cdepillabout/pretty-simple#readme + +-- | Pretty trace. Easier alias for traceShowId + pShow. ptrace :: Show a => a -> a ptrace = traceWith pshow @@ -157,7 +168,7 @@ traceAtWith f a = trace (f a) a ptraceAt :: Show a => Int -> String -> a -> a ptraceAt level | level > 0 && debugLevel < level = flip const - | otherwise = \s a -> let p = ppShow a + | otherwise = \s a -> let p = pshow a ls = lines p nlorspace | length ls > 1 = "\n" | otherwise = " " ++ take (10 - length s) (repeat ' ') @@ -303,7 +314,7 @@ plogAt :: Show a => Int -> String -> a -> a plogAt lvl | lvl > 0 && debugLevel < lvl = flip const | otherwise = \s a -> - let p = ppShow a + let p = pshow a ls = lines p nlorspace | length ls > 1 = "\n" | otherwise = " " ++ take (10 - length s) (repeat ' ') diff --git a/hledger-lib/hledger-lib.cabal b/hledger-lib/hledger-lib.cabal index 2358fac11..639c00ea6 100644 --- a/hledger-lib/hledger-lib.cabal +++ b/hledger-lib/hledger-lib.cabal @@ -1,10 +1,10 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.34.2. +-- This file has been generated from package.yaml by hpack version 0.33.0. -- -- see: https://github.com/sol/hpack -- --- hash: 24b8acde4649dda5e31d86c9f4f95744af97bae68f0e978144a55baf621d0bc8 +-- hash: 8be95614d73bb909eb29a27d8411f09623debad24f7fe84cf42ebc8b851a7ba8 name: hledger-lib version: 1.19.99 @@ -136,7 +136,7 @@ library , old-time , parsec >=3 , parser-combinators >=0.4.0 - , pretty-show >=1.6.4 + , pretty-simple >4 && <5 , regex-tdfa , safe >=0.2 , split >=0.1 @@ -189,7 +189,7 @@ test-suite doctest , old-time , parsec >=3 , parser-combinators >=0.4.0 - , pretty-show >=1.6.4 + , pretty-simple >4 && <5 , regex-tdfa , safe >=0.2 , split >=0.1 @@ -244,7 +244,7 @@ test-suite unittest , old-time , parsec >=3 , parser-combinators >=0.4.0 - , pretty-show >=1.6.4 + , pretty-simple >4 && <5 , regex-tdfa , safe >=0.2 , split >=0.1 diff --git a/hledger-lib/package.yaml b/hledger-lib/package.yaml index dd004e3b7..e7602049a 100644 --- a/hledger-lib/package.yaml +++ b/hledger-lib/package.yaml @@ -69,7 +69,7 @@ dependencies: - old-time - parsec >=3 - parser-combinators >=0.4.0 -- pretty-show >=1.6.4 +- pretty-simple >4 && <5 - regex-tdfa - safe >=0.2 - split >=0.1 diff --git a/hledger-ui/hledger-ui.cabal b/hledger-ui/hledger-ui.cabal index 5eebb6528..141a091f0 100644 --- a/hledger-ui/hledger-ui.cabal +++ b/hledger-ui/hledger-ui.cabal @@ -4,7 +4,7 @@ cabal-version: 1.12 -- -- see: https://github.com/sol/hpack -- --- hash: 057371c2b8cf46c32339a64339eaf98ac7247396cf8bb2dad13e99a5931cd62f +-- hash: 4e0beb8ffb64276b8f69f1bc9cf738199248509c23193799370132f748a74612 name: hledger-ui version: 1.19.99 @@ -83,7 +83,6 @@ executable hledger-ui , megaparsec >=7.0.0 && <9.1 , microlens >=0.4 , microlens-platform >=0.2.3.1 - , pretty-show >=1.6.4 , process >=1.2 , safe >=0.2 , split >=0.1 diff --git a/hledger-ui/package.yaml b/hledger-ui/package.yaml index fc75c0590..f3125db46 100644 --- a/hledger-ui/package.yaml +++ b/hledger-ui/package.yaml @@ -57,7 +57,6 @@ dependencies: - microlens >=0.4 - microlens-platform >=0.2.3.1 - megaparsec >=7.0.0 && <9.1 -- pretty-show >=1.6.4 - process >=1.2 - safe >=0.2 - split >=0.1 diff --git a/hledger/hledger.cabal b/hledger/hledger.cabal index 97e27d6d6..8cc38b417 100644 --- a/hledger/hledger.cabal +++ b/hledger/hledger.cabal @@ -4,7 +4,7 @@ cabal-version: 1.12 -- -- see: https://github.com/sol/hpack -- --- hash: 3becac2b267d30f6ce283af8e9b43dfa4f6ea374f6854da6c2272779fe3cb12c +-- hash: 4517e1a53a08aa05c53bb06d8591b5591f3ae6f688bf39f809c8f774fbd1d41c name: hledger version: 1.19.99 @@ -172,7 +172,6 @@ library , mtl >=2.2.1 , old-time , parsec >=3 - , pretty-show >=1.6.4 , process , regex-tdfa , safe >=0.2 @@ -223,7 +222,6 @@ executable hledger , mtl >=2.2.1 , old-time , parsec >=3 - , pretty-show >=1.6.4 , process , regex-tdfa , safe >=0.2 @@ -275,7 +273,6 @@ test-suite unittest , mtl >=2.2.1 , old-time , parsec >=3 - , pretty-show >=1.6.4 , process , regex-tdfa , safe >=0.2 @@ -326,7 +323,6 @@ benchmark bench , mtl >=2.2.1 , old-time , parsec >=3 - , pretty-show >=1.6.4 , process , regex-tdfa , safe >=0.2 diff --git a/hledger/package.yaml b/hledger/package.yaml index 8da3b3071..457b4a415 100644 --- a/hledger/package.yaml +++ b/hledger/package.yaml @@ -126,7 +126,6 @@ dependencies: - mtl >=2.2.1 - old-time - parsec >=3 -- pretty-show >=1.6.4 - process - regex-tdfa - safe >=0.2 diff --git a/stack.yaml b/stack.yaml index aee772457..c35655bb8 100644 --- a/stack.yaml +++ b/stack.yaml @@ -12,8 +12,10 @@ packages: - hledger-ui - hledger-web -# extra-deps: +extra-deps: # for hledger-lib: +- pretty-simple-4.0.0.0 +- prettyprinter-1.7.0 # for hledger: # for hledger-ui: # for hledger-web: diff --git a/stack8.0.yaml b/stack8.0.yaml index 894fb2394..e02ea4b76 100644 --- a/stack8.0.yaml +++ b/stack8.0.yaml @@ -78,3 +78,5 @@ extra-deps: - resourcet-1.2.4 - http-conduit-1.3.0 - monad-logger-0.3.28 +- pretty-simple-4.0.0.0 +- prettyprinter-1.7.0 diff --git a/stack8.10.yaml b/stack8.10.yaml index c42324077..1750460f5 100644 --- a/stack8.10.yaml +++ b/stack8.10.yaml @@ -12,4 +12,6 @@ packages: - hledger-ui - hledger-web -#extra-deps: +extra-deps: +- pretty-simple-4.0.0.0 +- prettyprinter-1.7.0 diff --git a/stack8.2.yaml b/stack8.2.yaml index 78c92423a..966d01682 100644 --- a/stack8.2.yaml +++ b/stack8.2.yaml @@ -42,3 +42,5 @@ extra-deps: - streaming-commons-0.2.1.2 - network-2.7.0.0 - math-functions-0.3.3.0 +- pretty-simple-4.0.0.0 +- prettyprinter-1.7.0 diff --git a/stack8.4.yaml b/stack8.4.yaml index 5ffa86d8d..c3e312b8d 100644 --- a/stack8.4.yaml +++ b/stack8.4.yaml @@ -25,3 +25,5 @@ extra-deps: - streaming-commons-0.2.1.2 - network-2.7.0.0 - math-functions-0.3.3.0 +- pretty-simple-4.0.0.0 +- prettyprinter-1.7.0 diff --git a/stack8.6.yaml b/stack8.6.yaml index 4110fc8b8..8737e926a 100644 --- a/stack8.6.yaml +++ b/stack8.6.yaml @@ -24,6 +24,8 @@ extra-deps: # - base-compat-0.11.0 # - http-api-data-0.4.1.1 # for hledger-lib: +- pretty-simple-4.0.0.0 +- prettyprinter-1.7.0 # for hledger: # for hledger-ui: # for hledger-web: