[GHC] #7742: StandaloneDeriving on Read fails for GADTs

GHC cvs-ghc at haskell.org
Tue Mar 5 21:10:20 CET 2013


#7742: StandaloneDeriving on Read fails for GADTs
--------------------------------------+-------------------------------------
Reporter:  hoffstaetter               |          Owner:                  
    Type:  bug                        |         Status:  new             
Priority:  normal                     |      Component:  Compiler        
 Version:  7.6.2                      |       Keywords:                  
      Os:  MacOS X                    |   Architecture:  Unknown/Multiple
 Failure:  GHC rejects valid program  |      Blockedby:                  
Blocking:                             |        Related:                  
--------------------------------------+-------------------------------------

Comment(by kosmikus):

 I think GHC is correct here.

 Ignoring `readsPrec` for simplicity and just looking at `read`, you are
 trying to derive a function of `String -> Foo a` here. But in order to
 produce a `Foo a`, we have to ''construct'' a `Read a` dictionary. And
 there's no way to come up with one for an arbitrary `a`. That's why you
 need an external `Read a` constraint.

 The situation is quite different for `Show`, because then you're provided
 with a `Foo a`, can extract the `Show` dictionary hidden within and use
 that to produce a textual representation of the `a`.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7742#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler



More information about the ghc-tickets mailing list