[GHC] #9206: OverloadedStrings breaks show?
GHC
ghc-devs at haskell.org
Wed Jun 18 11:43:27 UTC 2014
#9206: OverloadedStrings breaks show?
-------------------------------------+------------------------------------
Reporter: j80JjBjVNRMajmA | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.8.2
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):
This behaviour is mostly documented in the
[http://www.haskell.org/ghc/docs/latest/html/users_guide/type-class-
extensions.html#overloaded-strings overloaded strings section of the user
manual], although there is an important omission: with
`-XOverloadedStrings`, the default types (if none are specified by the
user) are `Integer, Double, String`, not just `Integer, Double`.
Reminder: `fromString :: IsString a => String -> a`, exported by
`GHC.Exts`.
So
* Without `-XOverloadedStrings`, `test.hs` is rightly rejected.
* With `-XOverloadedStrings`, defaulting kicks into play and chooses the
first type from `Integer, Double, String` that satisfies `(Show a0,
IsString a0)`. The only satisfying type is `String` so that is chosen.
* In `test2.hs`, `Double` is made an instance of `IsString`, so that is
picked first, before `String`.
So it all looks right except that the user manual is deficient. I'll fix
that.
Of course, you could argue that the specification is wrong. If you want
to do that, we should go back to the original discussion threads on
overloaded strings.
Simon
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9206#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list