
#11628: Unexpected results with Read/Show -------------------------------------+------------------------------------- Reporter: crockeea | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by rwbarton): Lots of distractions here. Here is the crux of the matter: {{{ newtype X u = X u instance Show u => Show (X u) where show (X u) = show u main = print (Just (X (Just 1))) -- prints "Just Just 1" }}} Of course, you should just define `showsPrec` like you mentioned. Just defining `show` should be okay if (either you don't care about compatibility with Read or) the output is a single token, like a number or a quoted string. Otherwise you need to define `showsPrec`. Agree that the docs should be clearer on this point. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11628#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler