[GHC] #11509: Incorrect error message in StandaloneDeriving: "The data constructors of <typeclass> are not all in scope"

GHC ghc-devs at haskell.org
Fri Jun 17 14:44:51 UTC 2016


#11509: Incorrect error message in StandaloneDeriving: "The data constructors of
<typeclass> are not all in scope"
-------------------------------------+-------------------------------------
        Reporter:  edsko             |                Owner:
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.0.1-rc1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by RyanGlScott):

 As Simon says, GHC's various `deriving` bits rely heavily on the
 assumption that the outermost type constructor is that of a datatype. I
 honestly have no idea how you'd make this work for typeclasses, especially
 since in your example, GHC would need some way to "tunnel down" into a
 type and figure out what the newtype is (if there even is one!). Throw in
 things like `MultiParamTypeClasses` and type synonyms, and I imagine that
 this would get extremely hairy.

 Would you be happy with a different error message to the tune of:

 {{{
 Bug1.hs:40:1: error:
     • Can't make a derived instance of ‘SC (Serializable (MyList a))’:
         Cannot derive an instance of the form ‘C (T a b c)‘
           where ‘T‘ is a type class
     • In the stand-alone deriving instance for
         ‘SC (Serializable a) => SC (Serializable (MyList a))’
 }}}

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


More information about the ghc-tickets mailing list