[GHC] #8207: Show instance for Language in DynFlags
GHC
ghc-devs at haskell.org
Sun Sep 1 05:02:13 CEST 2013
#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
More information about the ghc-tickets
mailing list