pretty-show 1.9.3 → 1.9.4
raw patch · 4 files changed
+24/−6 lines, 4 files
Files
- CHANGELOG +3/−0
- Text/Show/Pretty.hs +17/−2
- bin/ppsh.hs +3/−3
- pretty-show.cabal +1/−1
CHANGELOG view
@@ -1,3 +1,6 @@+Changes in 1.9.4+ * Fix issue #35+ Changes in 1.9.3 * Fix issue #34
Text/Show/Pretty.hs view
@@ -13,6 +13,7 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE Safe #-}+{-# LANGUAGE PatternGuards #-} module Text.Show.Pretty ( -- * Generic representation of values Value(..), Name@@ -42,13 +43,14 @@ , ppValue ) where +import Data.Char(isHexDigit) import Text.PrettyPrint import qualified Text.Show.Parser as P import Text.Show.Value import Text.Show.PrettyVal import Text.Show.Html import Data.Foldable(Foldable,toList)-import Language.Haskell.Lexer(rmSpace,lexerPass0)+import Language.Haskell.Lexer(rmSpace,lexerPass0,Token(..)) import Paths_pretty_show (getDataDir) #if MIN_VERSION_base(4,11,0)@@ -65,7 +67,20 @@ reify = parseValue . show parseValue :: String -> Maybe Value-parseValue = P.parseValue . rmSpace . lexerPass0+parseValue = P.parseValue . rmSpace . foldr joinTokens [] . lexerPass0+ where++ -- Sometimes we join tokens that are next to each other, with no spaces.+ -- This improves the printing of some malformed inputs:+ -- * Hex numbers with no 0x: "4ab" instead of "4 ab"+ joinTokens a@(t1,(p1,s1)) bs =+ case bs of+ (_t2,(_,s2)) : more+ | IntLit <- t1, all isHexDigit s2 -> jn IntLit+ where jn t = (t,(p1,s1++s2)) : more++ _ -> a : bs+ -- | Convert a generic value into a pretty 'String', if possible. ppShow :: Show a => a -> String
bin/ppsh.hs view
@@ -11,7 +11,7 @@ let (opts,hiding) = partitionEithers (map isHiding as) preproc v = case hiding of [] -> v- xs -> hideCon False (`elem` hiding) v+ _ -> hideCon False (`elem` hiding) v case opts of ["--test"] -> interactLn (show . selftest1) @@ -20,10 +20,10 @@ case parseValue txt of Just v -> do dir <- getDataDir- let opts = defaultHtmlOpts { dataDir = dir }+ let optis = defaultHtmlOpts { dataDir = dir } -- XXX: perhaps for HTML the "hidden" values should -- just start off collapsed, rahter than being deleted?- putStrLn (valToHtmlPage opts (preproc v))+ putStrLn (valToHtmlPage optis (preproc v)) Nothing -> hPutStrLn stderr "Failed to parse value." [] -> interactLn $ \s -> case parseValue s of
pretty-show.cabal view
@@ -1,5 +1,5 @@ name: pretty-show-version: 1.9.3+version: 1.9.4 category: Text synopsis: Tools for working with derived `Show` instances and generic