packages feed

unicode-show 0.1.0.5 → 0.1.1.0

raw patch · 2 files changed

+18/−4 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Text.Show.Unicode: urecover :: String -> String
+ Text.Show.Unicode: urecoverWith :: (Char -> Bool) -> String -> String

Files

src/Text/Show/Unicode.hs view
@@ -47,7 +47,7 @@  -} -module Text.Show.Unicode (ushow, uprint, ushowWith, uprintWith) where+module Text.Show.Unicode (ushow, uprint, urecover, ushowWith, uprintWith, urecoverWith) where  import           Control.Applicative          ((<|>)) import           Data.Char                    (isAscii, isPrint)@@ -95,8 +95,17 @@ -- with the character it represents, for any Unicode printable characters except backslash, single and double quotation marks. -- If something fails, fallback to standard 'show'. ushow :: Show a => a -> String-ushow = ushowWith (\c -> isPrint c && not (isAscii c))+ushow = ushowWith shouldRecover +-- | Replace Haskell character literals with the character it represents, for+-- any Unicode printable characters except backslash, single and double+-- quotation marks.+urecover :: String -> String+urecover = urecoverWith shouldRecover++shouldRecover :: Char -> Bool+shouldRecover c = isPrint c && not (isAscii c)+ -- | A version of 'print' that uses 'ushow'. uprint :: Show a => a -> IO () uprint = putStrLn . ushow@@ -104,7 +113,12 @@ -- | Show the input, and then replace character literals -- with the character itself, for characters that satisfy the given predicate. ushowWith :: Show a => (Char -> Bool) -> a -> String-ushowWith p x = go ("", "") $ readP_to_S (many $ recoverChar p) (show x)+ushowWith p = urecoverWith p . show++-- | Replace character literals with the character itself, for characters that+-- satisfy the given predicate.+urecoverWith :: (Char -> Bool) -> String -> String+urecoverWith p = go ("", "") . readP_to_S (many $ recoverChar p)   where     go :: Replacement -> [([Replacement], String)] -> String     go _  []            = ""
unicode-show.cabal view
@@ -1,5 +1,5 @@ name:                unicode-show-version:             0.1.0.5+version:             0.1.1.0 synopsis:            print and show in unicode description:             This package provides variants of 'show' and 'print' functions that does not escape non-ascii characters.