#7199: Standalone deriving Show at GHCi prompt causes divergence when printing
-------------------------+--------------------------------------------------
Reporter: dpmulligan | Owner:
Type: bug | Status: closed
Priority: normal | Milestone:
Component: GHCi | Version: 7.4.1
Resolution: invalid | Keywords: deriving, divergence, ghci
Os: Linux | Architecture: x86
Failure: GHCi crash | Difficulty: Unknown
Testcase: | Blockedby:
Blocking: | Related:
-------------------------+--------------------------------------------------
Changes (by simonpj):
* status: new => closed
* difficulty: => Unknown
* resolution: => invalid
Comment:
This code
{{{
instance Show Bool'
}}}
does not derive a `Show` instance. To do that you need to either say
{{{
data Bool' = T' | F' deriving( Show )
}}}
or you can use standalone deriving (with `-XStandaloneDeriving`):
{{{
deriving instance Show Bool'
}}}
By merely saying `instance Show Bool'` you are using ordinary Haskell 98
to define an instance, filling in the default methods as desribed in the
language specficiation. So it's as if you'd typed
{{{
instance Show Bool' where
show x = showsPrec 0 x ""
showsPrec _ x s = show x ++ s
}}}
(The default declarations come from the library.) Since each method is
defined in terms of the other, the result diverges.
Simon
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7199#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs