[GHC] #9334: Implement "instance chains"

GHC ghc-devs at haskell.org
Sun Aug 10 20:07:54 UTC 2014


#9334: Implement "instance chains"
-------------------------------------+-------------------------------------
              Reporter:  diatchki    |            Owner:  diatchki
                  Type:  feature     |           Status:  new
  request                            |        Milestone:
              Priority:  normal      |          Version:  7.9
             Component:  Compiler    |         Keywords:
  (Type checker)                     |     Architecture:  Unknown/Multiple
            Resolution:              |       Difficulty:  Unknown
      Operating System:              |       Blocked By:
  Unknown/Multiple                   |  Related Tickets:
       Type of failure:              |
  None/Unknown                       |
             Test Case:              |
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------

Comment (by diatchki):

 I've chatted with Mark and Garrett (the authors of the "Instance Chains"
 papers) and we've decided that there are really three separate features
 here:

   1. "Instance Groups", which is what is outlined in this ticket, and
 enables programmers to order instances explicitly, rather than using
 more/less general realtions.

   2. "Fails instances", which are of the form `instance Num Char fails`;
 they enable programmers to state explicitly that an instance should never
 exits.  Interestingly, I just found a very related ticket asking for the
 same sort of thing (#7775).

   3. "Using instance contexts when selecting instances (aka
 backtracking)": currently, if the head of an instance matches a goal, GHC
 commits to it and then fails if it encounters an error;  an alternative
 design would be to back-track and try a different option (e.g., next
 member of an instance group, or a more general matching instance).


 I think that (1) and (2) are useful and shouldn't be too hard to implement
 in GHC.  (3), however, seems like more work.  Also, there are programs
 that rely on GHC's current behavior.

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


More information about the ghc-tickets mailing list