#4529: Deriving Data does not work for attached code
--------------------------------------+-------------------------------------
  Reporter:  mitar                    |          Owner:                  
      Type:  bug                      |         Status:  closed          
  Priority:  normal                   |      Milestone:                  
 Component:  Compiler (Type checker)  |        Version:  7.1             
Resolution:  invalid                  |       Keywords:                  
  Testcase:                           |      Blockedby:                  
Difficulty:                           |             Os:  Unknown/Multiple
  Blocking:                           |   Architecture:  Unknown/Multiple
   Failure:  None/Unknown             |  
--------------------------------------+-------------------------------------
Changes (by simonpj):

  * status:  new => closed
  * resolution:  => invalid


Comment:

 You have
 {{{
 data (Real r, Show r, Random r, Data r)
   => RandomFoo r = RandomFoo (RandomBar r)
   deriving (Typeable, Data)
 }}}
 As you'll see if you say `-ddump-deriv` (I'm improving the layout) you get
 a `Data` instance with `(Real r, Random r)` in the context?  Why?  Because
 the instance pattern matches on the constructor.

 Solution: simply remove the context from the `data` declaration, giving
 {{{
 data RandomFoo r = RandomFoo (RandomBar r)
   deriving (Typeable, Data)
 }}}
 The context (which is a Haskell mis-feature) does you no good, and as you
 have seen, it does you harm.

 Simon

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4529#comment:3>
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

Reply via email to