unicode-show-0.1.0.2: print and show in unicode

Copyright | (c) Takayuki Muranushi 2016
License | MIT
Maintainer | muranushi@gmail.com
Stability | experimental
Safe Haskell | Safe
Language | Haskell2010

Text.Show.Unicode

Description

Provides a interactive printer for printing Unicode characters in ghci REPL. Our design goal is that `uprint` produces String representations that are valid Haskell `String` literals and uses as many Unicode printable characters as possible. Hence

    read . ushow == id

see the tests of this package for detailed specifications.

Example

With `print` :

    $ ghci
    ...
    > ["哈斯克尔7.6.1"]
    ["\21704\26031\20811\23572\&7.6.1"]
    >

With `uprint` :

    $ ghci -interactive-print=Text.Show.Unicode.uprint Text.Show.Unicode
    ...
    Ok, modules loaded: Text.Show.Unicode.
    > ("Хорошо!",["哈斯克尔7.6.1的力量","感じる"])
    ("Хорошо!",["哈斯克尔7.6.1的力量","感じる"])
    > "改\n行"
    "改\n行"

You can make `uprint` the default interactive printer in several ways. One is to `cabal install unicode-show`, and add the following lines to your `~/.ghci` config file.

    import qualified Text.Show.Unicode
    :set -interactive-print=Text.Show.Unicode.uprint

Synopsis

- ushow :: Show a => a -> String
- uprint :: Show a => a -> IO ()
- ushowWith :: Show a => (Char -> Bool) -> a -> String
- uprintWith :: Show a => (Char -> Bool) -> a -> IO ()

# Documentation

ushow :: Show a => a -> String #

Show the input, and then replace Haskell character literals with the character it represents, for any Unicode printable characters except backslash, single and double quotation marks. If something fails, fallback to standard `show`.

uprint :: Show a => a -> IO () #

A version of `print` that uses `ushow`.

ushowWith :: Show a => (Char -> Bool) -> a -> String #

Show the input, and then replace character literals with the character itself, for characters that satisfy the given predicate.

uprintWith :: Show a => (Char -> Bool) -> a -> IO () #

A version of `print` that uses `ushowWith`.