[GHC] #11008: Difficulties around inferring exotic contexts

GHC ghc-devs at haskell.org
Tue Oct 27 13:42:32 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):

 All I'm suggesting is that rather than the iterative process of

   1. GHC writes an instance
   2. GHC checks for a (single?) matching instance head for all constraints
   3. GHC simplifies those constraints
   4. Go to step 1 until minimal constraints found

 (which I refer to as the "simplify and reject" method), GHC could get to
 step 3, and then just continue to simplify the constraints ''without''
 checking for matching instances on all ''simplified'' constraints (i.e.
 more like how a function (presumably) simplifies constraints, which I
 refer to as the "simplify and typecheck" method, where no rejection occurs
 if no matching instance is found).

 Thus GHC would still require a standalone instance for `data X a b = MkX
 (a -> b) deriving Eq` because step (in the first round) would fail. The
 idea is that the above process would allow auto-deriving when a single
 matching instance is found for the unsimplified context. In the case of
 overlapping or missing instances, I have no opinion on the behavior.


 Maybe this approach is too ad-hoc, but I think it would result in expected
 behavior.

 My main reasons for this are that
   1. If there's a single instance in scope, GHC should assume I know how
 to use it.
   2. Writing the standalone instance `deriving instance (Eq (Foo r)) => Eq
 (Bar r)` does ''nothing'' to help me understand the exotic nature of the
 instance. [Not that I feel like I want advice in this area, mind you. I
 want GHC to assume I know what I'm doing.]

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


More information about the ghc-tickets mailing list