Changes between Initial Version and Version 1 of Ticket #7099


Ignore:
Timestamp:
Jul 26, 2012 10:26:46 AM (21 months ago)
Author:
pcapriotti
Comment:

This is expected behavior. The Show class defines defaults for all its methods, and the instance Show C line creates an empty instance where all the defaults are used, resulting in a non-terminating definition of show.

If for some reason you want a standalone deriving statement, use -XStandaloneDeriving and

deriving instance Show C

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #7099

    • Property Status changed from new to closed
    • Property Difficulty changed from to Unknown
    • Property Resolution changed from to invalid
  • Ticket #7099 – Description

    initial v1  
    11When I load the code below in ghci and run 'create :: C' the execution ends after a while with a stack overflow.  However, when I delete the line 'instance Show C' and erase the '--' before 'deriving (Show)' the command 'create :: C' delivers a 'C' as I would expect it.  
    22 
    3 > module Main where[[BR]] 
    4 >[[BR]] 
    5 > data C = C --deriving (Show)[[BR]] 
    6 >[[BR]] 
    7 > instance Show C[[BR]] 
    8 >[[BR]] 
    9 > class T m where[[BR]] 
    10 >       create :: m [[BR]] 
    11 > 
    12 > instance T C where[[BR]] 
    13 >       create = C[[BR]] 
     3{{{ 
     4module Main where 
     5 
     6data C = C --deriving (Show)[[BR]] 
     7 
     8instance Show C 
     9 
     10class T m where 
     11     create :: m 
     12 
     13instance T C where 
     14     create = C 
     15}}}