[GHC] #10592: Allow cycles in class declarations

GHC ghc-devs at haskell.org
Wed Jul 1 07:13:08 UTC 2015


#10592: Allow cycles in class declarations
-------------------------------------+-------------------------------------
        Reporter:  MikeIzbicki       |                   Owner:
            Type:  feature request   |                  Status:  new
        Priority:  normal            |               Milestone:
       Component:  Compiler (Type    |                 Version:  7.10.1
  checker)                           |                Keywords:
      Resolution:                    |            Architecture:
Operating System:  Unknown/Multiple  |  Unknown/Multiple
 Type of failure:  None/Unknown      |               Test Case:
      Blocked By:                    |                Blocking:
 Related Tickets:                    |  Differential Revisions:
-------------------------------------+-------------------------------------
Changes (by adamgundry):

 * cc: adamgundry (added)


Comment:

 Somewhat surprisingly, this appears to be a valid workaround:
 {{{
 {-# LANGUAGE TypeFamilies #-}
 {-# LANGUAGE ConstraintKinds #-}
 {-# LANGUAGE UndecidableInstances #-}

 type family Scalar x

 type family FieldScalar x where FieldScalar x = Field (Scalar x)

 class FieldScalar x => Vector x

 class Vector x => Field x
 }}}
 I suspect the `"Cycle in class declaration (via superclasses)"` error is a
 little bit too conservative.

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


More information about the ghc-tickets mailing list