[GHC] #16031: Show instance for Data.Fixed does not show parentheses for negatives

GHC ghc-devs at haskell.org
Tue Dec 11 17:46:07 UTC 2018


#16031: Show instance for Data.Fixed does not show parentheses for negatives
-------------------------------------+-------------------------------------
           Reporter:  skeuchel       |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:                 |           Version:  8.7
  libraries/base                     |
           Keywords:  Data.Fixed,    |  Operating System:  Unknown/Multiple
  Show                               |
       Architecture:                 |   Type of failure:  Incorrect result
  Unknown/Multiple                   |  at runtime
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 When showing negative numbers most types emit parentheses in precedence
 level 11 because the result is not atomic:

 {{{#!hs
 GHCi, version 8.7.20181015: http://www.haskell.org/ghc/  :? for help
 Prelude> show (Just (-1 :: Int))
 "Just (-1)"
 Prelude> show (Just (-1 :: Float))
 "Just (-1.0)"
 }}}

 However, the Show instance for Fixed does not

 {{{#!hs
 Prelude> :m Data.Fixed
 Prelude Data.Fixed> show (Just (-1 :: Fixed E2))
 "Just -1.00"
 Prelude Data.Fixed>
 }}}

 I would expect it to, because of consistency and because the result "Just
 -1.00" is ill-typed when seen as an expression.

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


More information about the ghc-tickets mailing list