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

#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

#16031: Show instance for Data.Fixed does not show parentheses for negatives -------------------------------------+------------------------------------- Reporter: skeuchel | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: libraries/base | Version: 8.7 Resolution: | Keywords: Data.Fixed, | Show, newcomer 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: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * keywords: Data.Fixed, Show => Data.Fixed, Show, newcomer Comment: Good catch. I wouldn't expect this to be difficult to fix—we'd just need to change the `Show` instance such that negative `Fixed` values are parenthesized with a sufficiently high precedence value. For inspiration, one can look at the existing [http://git.haskell.org/ghc.git/blob/4b3022021d49778bcd29a57308dbe0a076549f1b... Show Integer instance], which parenthesizes negative `Integer`s when the precedence is higher than 6. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16031#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16031: Show instance for Data.Fixed does not show parentheses for negatives -------------------------------------+------------------------------------- Reporter: skeuchel | Owner: supersven Type: bug | Status: new Priority: normal | Milestone: Component: libraries/base | Version: 8.7 Resolution: | Keywords: Data.Fixed, | Show, newcomer 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: | -------------------------------------+------------------------------------- Changes (by supersven): * owner: (none) => supersven -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16031#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16031: Show instance for Data.Fixed does not show parentheses for negatives -------------------------------------+------------------------------------- Reporter: skeuchel | Owner: supersven Type: bug | Status: patch Priority: normal | Milestone: Component: libraries/base | Version: 8.7 Resolution: | Keywords: Data.Fixed, | Show, newcomer 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: | -------------------------------------+------------------------------------- Changes (by supersven): * status: new => patch Comment: Hey, I created a merge request: https://gitlab.haskell.org/ghc/ghc/merge_requests/41 Best regards, Sven -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16031#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16031: Show instance for Data.Fixed does not show parentheses for negatives -------------------------------------+------------------------------------- Reporter: skeuchel | Owner: supersven Type: bug | Status: closed Priority: normal | Milestone: Component: libraries/base | Version: 8.7 Resolution: fixed | Keywords: Data.Fixed, | Show, newcomer 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: | -------------------------------------+------------------------------------- Changes (by supersven): * status: patch => closed * resolution: => fixed Comment: Was merged to master (https://gitlab.haskell.org/ghc/ghc/merge_requests/82). Thanks to @ggreif and @bgamari! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16031#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16031: Show instance for Data.Fixed does not show parentheses for negatives -------------------------------------+------------------------------------- Reporter: skeuchel | Owner: supersven Type: bug | Status: closed Priority: normal | Milestone: 8.8.1 Component: libraries/base | Version: 8.7 Resolution: fixed | Keywords: Data.Fixed, | Show, newcomer 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: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * milestone: => 8.8.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16031#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16031: Show instance for Data.Fixed does not show parentheses for negatives -------------------------------------+------------------------------------- Reporter: skeuchel | Owner: supersven Type: bug | Status: closed Priority: normal | Milestone: 8.8.1 Component: libraries/base | Version: 8.7 Resolution: fixed | Keywords: Data.Fixed, | Show, newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Incorrect result | Test Case: at runtime | libraries/base/tests/data-fixed- | show-read Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * testcase: => libraries/base/tests/data-fixed-show-read -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16031#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16031: Show instance for Data.Fixed does not show parentheses for negatives
-------------------------------------+-------------------------------------
Reporter: skeuchel | Owner: supersven
Type: bug | Status: closed
Priority: normal | Milestone: 8.8.1
Component: libraries/base | Version: 8.7
Resolution: fixed | Keywords: Data.Fixed,
| Show, newcomer
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: Incorrect result | Test Case:
at runtime | libraries/base/tests/data-fixed-
| show-read
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#16031: Show instance for Data.Fixed does not show parentheses for negatives
-------------------------------------+-------------------------------------
Reporter: skeuchel | Owner: supersven
Type: bug | Status: closed
Priority: normal | Milestone: 8.8.1
Component: libraries/base | Version: 8.7
Resolution: fixed | Keywords: Data.Fixed,
| Show, newcomer
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: Incorrect result | Test Case:
at runtime | libraries/base/tests/data-fixed-
| show-read
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari
participants (1)
-
GHC