[GHC] #8207: Show instance for Language in DynFlags

#8207: Show instance for Language in DynFlags ------------------------------------+------------------------------------- Reporter: Fuuzetsu | Owner: Type: feature request | Status: new Priority: low | Milestone: Component: GHC API | Version: 7.7 Keywords: | Operating System: Unknown/Multiple Architecture: Unknown/Multiple | Type of failure: None/Unknown Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | ------------------------------------+------------------------------------- I feel that the GHC API could benefit from a Show instance for Language in DynFlags.hs. Currently, if we want to display the language being used we have to do something like {{{ foo inf = case hmi_language inf of Nothing -> Nothing Just Haskell98 -> Just "Haskell98" Just Haskell2010 -> Just "Haskell2010" }}} This is pretty much just the Show instance (over Maybe) and Haskell can derive it for us automatically: we just need to change `deriving Enum` to `deriving (Enum, Show)`. The above solution is not the most robust ever as if this data type is ever changed, this starts to form an incomplete pattern. If we have a catch all `_`, GHC complains about overlapping patterns. Easily solved with `show <$> hmi_language inf`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8207 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8207: Pretty Printer for textual version of Language (name) in DynFlags -------------------------------------+------------------------------------ Reporter: Fuuzetsu | Owner: Type: feature request | Status: new Priority: low | Milestone: Component: GHC API | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by carter): to further clarify, based upon further discussion on IRC, {{{ [23:39:41] <Fuuzetsu> Yep, all I want is Language -> String out of only having DynFlags which provides Maybe Language. }}} Its worth noting that this probably shouldn't be a show instance, because Language Standards need not have only the form (capital letter)(aphanumeric*). The key point is a function to pretty print the name of the Language should be exposed. And probably more future proof to funny names if its not done via Show specifically. ie {{{ renderLanguageName :: Language -> String }}} or the like -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8207#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8207: Pretty Printer for textual version of Language (name) in DynFlags -------------------------------------+------------------------------------ Reporter: Fuuzetsu | Owner: Type: feature request | Status: new Priority: low | Milestone: Component: GHC API | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by simonpj): OK with me; maybe send patch? Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8207#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8207: Pretty Printer for textual version of Language (name) in DynFlags -------------------------------------+------------------------------------- Reporter: Fuuzetsu | Owner: Type: feature request | Status: new Priority: low | Milestone: Component: GHC API | Version: 7.7 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by thomie): * keywords: => newcomer -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8207#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8207: Pretty Printer for textual version of Language (name) in DynFlags -------------------------------------+------------------------------------- Reporter: Fuuzetsu | Owner: seraphime Type: feature request | Status: new Priority: low | Milestone: Component: GHC API | Version: 7.7 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by seraphime): * owner: => seraphime -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8207#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8207: Pretty Printer for textual version of Language (name) in DynFlags -------------------------------------+------------------------------------- Reporter: Fuuzetsu | Owner: seraphime Type: feature request | Status: closed Priority: low | Milestone: 8.0.1 Component: GHC API | Version: 7.7 Resolution: fixed | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => closed * resolution: => fixed * milestone: => 8.0.1 @@ -7,1 +7,1 @@ - {{{ + {{{#!hs New description: I feel that the GHC API could benefit from a Show instance for Language in DynFlags.hs. Currently, if we want to display the language being used we have to do something like {{{#!hs foo inf = case hmi_language inf of Nothing -> Nothing Just Haskell98 -> Just "Haskell98" Just Haskell2010 -> Just "Haskell2010" }}} This is pretty much just the Show instance (over Maybe) and Haskell can derive it for us automatically: we just need to change `deriving Enum` to `deriving (Enum, Show)`. The above solution is not the most robust ever as if this data type is ever changed, this starts to form an incomplete pattern. If we have a catch all `_`, GHC complains about overlapping patterns. Easily solved with `show <$> hmi_language inf`. -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8207#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8207: Pretty Printer for textual version of Language (name) in DynFlags -------------------------------------+------------------------------------- Reporter: Fuuzetsu | Owner: seraphime Type: feature request | Status: closed Priority: low | Milestone: 8.0.1 Component: GHC API | Version: 7.7 Resolution: fixed | Keywords: newcomer 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 bgamari): An `Outputable` instance for this was added in 2ad46a860f0b648aaeff224109b6045da30304d7. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8207#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC