[GHC] #11008: Difficulties around inferring exotic contexts

GHC ghc-devs at haskell.org
Fri Oct 23 16:24:41 UTC 2015


#11008: Difficulties around inferring exotic contexts
-------------------------------------+-------------------------------------
        Reporter:  crockeea          |                Owner:
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  7.10.2
      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 crockeea):

 With the deriving clause, which instance does GHC try to create?

   1. instance (Eq (Foo r)) => Eq (Bar r)
   2. instance (C (F r), Eq r) => Eq (Bar r)

 If option 1, GHC has no business inspecting the constraints on the `Foo r`
 instance. If option 2, why? Is it due to
 [https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/deriving.html
 #newtype-deriving slower instances]?

 In either case, since I *have* a matching `Eq` instance for `Foo`, GHC
 should assume that I knew what I was doing when I wrote it, and just use
 it. This doesn't change the behavior when no matching instance is found,
 like in your example.

 Whatever the result, the docs definitely need to be clearer.

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


More information about the ghc-tickets mailing list