[GHC] #11529: Show instance of Char should print literals for non-ascii printable charcters

GHC ghc-devs at haskell.org
Wed Feb 3 02:43:41 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 nushio):

 One of application that is broken by this change, is when a customized
 Show instance of a type is controlled by other variables in that type. For
 example, the following code simulates a press code that respects privacy
 for people of age under 20.

 {{{#!hs
 data Sex = Male | Female
 data Person = Person {name :: String, age :: Int, sex :: Sex}

 instance Show Person where
   show (Person _ a Male  ) | a < 20 = "A boy (" ++ show a ++ ")"
   show (Person _ a Female) | a < 20 = "A girl (" ++ show a ++ ")"
   show (Person n a _     )          = n

 assert $ show (Person "村主崇行" 19 Male) == "A boy (19)"
 assert $ show (Person "村主崇行" 20 Male) == "\26449\20027\23815\34892"
 }}}

 I'm very looking forward to learn other drawbacks of this change.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11529#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list