[GHC] #10592: Allow cycles in class declarations

GHC ghc-devs at haskell.org
Fri Dec 18 11:26:08 UTC 2015


#10592: Allow cycles in class declarations
-------------------------------------+-------------------------------------
        Reporter:  MikeIzbicki       |                Owner:
            Type:  feature request   |               Status:  infoneeded
        Priority:  normal            |            Milestone:
       Component:  Compiler (Type    |              Version:  7.10.1
  checker)                           |
      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 simonpj):

 OK I've got it.  Patch coming.

 Your example differs from Edward's in #10318, because you really do have
 an infinite stack of superclasses.

 * `Eq a` has `Boolean (Logic a)` as a superclass
 * `Boolean a` ultimately has `Eq a` as a superclass

 So we get `Eq (Logic a)`, `Eq (Logic (Logic a))`, etc forever.

 Do you really mean that.  Edward cut this off by adding a constraint
 {{{
 Frac (Frac a) ~ Frac a
 }}}
 Can you do something like that for `Logic`?

 If you really really do have infinitely many superclasses then unsolved
 constraints will indeed hit the iteration limit as you found... GHC keeps
 adding superclasses in the hope of finding one that works, but there are
 infinitely many of them (I fixed the error  message to give the right flag
 name, but it doesn't solve the problem).  I don't see any way to solve
 this without you giving GHC some way to bound the tower as Edward did.

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


More information about the ghc-tickets mailing list