
#9206: OverloadedString breaks show? ------------------------------------+------------------------------------- Reporter: j80JjBjVNRMajmA | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Keywords: | Operating System: Unknown/Multiple Architecture: Unknown/Multiple | Type of failure: None/Unknown Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | ------------------------------------+------------------------------------- The file `test.hs` contains {{{ import GHC.Exts main = putStrLn $ show (fromString "01") }}} and results in: `ghc -XNoOverloadedStrings test.hs` {{{ overloadedString.hs:4:20: No instance for (Show a0) arising from a use of ‘show’ The type variable ‘a0’ is ambiguous Note: there are several potential instances: instance Show Double -- Defined in ‘GHC.Float’ instance Show Float -- Defined in ‘GHC.Float’ instance (Integral a, Show a) => Show (GHC.Real.Ratio a) -- Defined in ‘GHC.Real’ ...plus 44 others In the second argument of ‘($)’, namely ‘show (fromString "01")’ In the expression: putStrLn $ show (fromString "01") In an equation for ‘main’: main = putStrLn $ show (fromString "01") overloadedString.hs:4:26: No instance for (IsString a0) arising from a use of ‘fromString’ The type variable ‘a0’ is ambiguous Note: there is a potential instance available: instance IsString [Char] -- Defined in ‘Data.String’ In the first argument of ‘show’, namely ‘(fromString "01")’ In the second argument of ‘($)’, namely ‘show (fromString "01")’ In the expression: putStrLn $ show (fromString "01") }}} OverloadedStrings breaks things (by making them magically work, which is probably why nobody complained?) `ghc -XOverloadedStrings -e main test.hs` {{{ "01" }}} and another `test2.hs`: {{{ import GHC.Exts instance IsString Double where fromString = read main = putStrLn $ show (fromString "01") }}} `ghc -XOverloadedStrings -e main test2.hs` {{{ "1.0" }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9206 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler