[GHC] #11529: Show instance of Char should print literals for non-ascii printable charcters
GHC
ghc-devs at haskell.org
Thu Mar 31 01:11:44 UTC 2016
#11529: Show instance of Char should print literals for non-ascii printable
charcters
-------------------------------------+-------------------------------------
Reporter: nushio | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.10.3
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by chak):
Replying to [comment:2 dfeuer]:
> Absolutely any code in the entire world that relies on the current
behavior will break. The current behavior is expressed in the reference
implementation in the Haskell 2010 report. Frankly, changing it ''is not
an option''. You can write your own function to unescape valid Unicode.
You can also write your own `UShow` class if you like with a method for
showing various things using Unicode generally. You can then try to
convince other developers to depend on your package and write instances of
your class.
I disagree. I think, the current implementation is actually wrong and does
not adhere to the standard. The standard states in 16.6 that `showLitChar`
be defined as follows:
> Convert a character to a string using only printable characters, using
Haskell source-language escape conventions.
However, the current implementation of `showLitChar` fail to use
`isPrint`; instead it uses a naive condition, `c > '\DEL'`, to determine
printability. This is wrong.
The solution is simple, replace the condition `c > '\DEL'` by `not
(isPrint c)` in the definition of `showLitChar`.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11529#comment:15>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list