pretty-simple 3.2.2.0 → 3.2.3.0
raw patch · 3 files changed
+23/−6 lines, 3 files
Files
- CHANGELOG.md +7/−0
- pretty-simple.cabal +1/−1
- src/Text/Pretty/Simple/Internal/ExprParser.hs +15/−5
CHANGELOG.md view
@@ -1,4 +1,11 @@ +## 3.2.3.0++* Fix a bug that messes up printing identifiers with `'` in the name.+ Now identifiers like `data Don't = Don't` show up properly.+ [#65](https://github.com/cdepillabout/pretty-simple/pull/65)+ Thanks George Thomas ([@georgefst](https://github.com/georgefst))!+ ## 3.2.2.0 * Remove whitespace from the ends of lines.
pretty-simple.cabal view
@@ -1,5 +1,5 @@ name: pretty-simple-version: 3.2.2.0+version: 3.2.3.0 synopsis: pretty printer for data types with a 'Show' instance. description: Please see <https://github.com/cdepillabout/pretty-simple#readme README.md>. homepage: https://github.com/cdepillabout/pretty-simple
src/Text/Pretty/Simple/Internal/ExprParser.hs view
@@ -138,9 +138,10 @@ -- This is almost the same as the function -- -- > parseOtherSimple = span $ \c ->--- > notElem c ("{[()]}\"," :: String) && not (isDigit c)+-- > notElem c ("{[()]}\"," :: String) && not (isDigit c) && (c /= '\'') ----- except 'parseOther' ignores digits that appear in Haskell-like identifiers.+-- except 'parseOther' ignores digits and single quotes that appear in+-- Haskell-like identifiers. -- -- >>> parseOther "hello world []" -- ("hello world ","[]")@@ -152,6 +153,12 @@ -- ("hello","{[ 234 world") -- >>> parseOther "H3110 World" -- ("H3110 World","")+-- >>> parseOther "Node' (Leaf' 1) (Leaf' 2)"+-- ("Node' ","(Leaf' 1) (Leaf' 2)")+-- >>> parseOther "I'm One"+-- ("I'm One","")+-- >>> parseOther "I'm 2"+-- ("I'm ","2") parseOther :: String -> (String, String) parseOther = go False where@@ -162,8 +169,8 @@ -> (String, String) go _ [] = ("", "") go insideIdent cs@(c:cs')- | c `elem` ("{[()]}\"'," :: String) = ("", cs)- | isDigit c && not insideIdent = ("", cs)+ | c `elem` ("{[()]}\"," :: String) = ("", cs)+ | ignoreInIdent c && not insideIdent = ("", cs) | insideIdent = first (c :) (go (isIdentRest c) cs') | otherwise = first (c :) (go (isIdentBegin c) cs') @@ -174,4 +181,7 @@ isIdentRest :: Char -> Bool isIdentRest '_' = True isIdentRest '\'' = True- isIdentRest c = isAlpha c || isDigit c+ isIdentRest c = isAlpha c || ignoreInIdent c++ ignoreInIdent :: Char -> Bool+ ignoreInIdent x = isDigit x || x == '\''