[GHC] #10300: GHC rejects typeclass with associated type

GHC ghc-devs at haskell.org
Tue Apr 14 11:15:20 UTC 2015


#10300: GHC rejects typeclass with associated type
-------------------------------------+-------------------------------------
        Reporter:  mhwombat          |                   Owner:
            Type:  bug               |                  Status:  closed
        Priority:  normal            |               Milestone:
       Component:  Compiler          |                 Version:  7.10.1
      Resolution:  invalid           |                Keywords:
Operating System:  Unknown/Multiple  |            Architecture:
 Type of failure:  GHC rejects       |  Unknown/Multiple
  valid program                      |               Test Case:
      Blocked By:                    |                Blocking:
 Related Tickets:  10020             |  Differential Revisions:
-------------------------------------+-------------------------------------
Changes (by simonpj):

 * status:  new => closed
 * resolution:   => invalid


Comment:

 There's nothing to connect `Size` with `FiniteGrid`; it's not an
 ''associated'' type at all.  You can just define it separately:
 {{{
 type family Size s

 class FiniteGrid g where
   size :: g -> Size g
   maxPossibleDistance :: g -> Int
 }}}
 Or, if you want to guarantee you always have an instance of `Size g`
 whenever you have an instance of `FiniteGrid g`, then use `g` in `Size`'s
 definition:
 {{{
 class FiniteGrid g where
   type Size g
   size :: g -> Size g
   maxPossibleDistance :: g -> Int
 }}}
 This isn't a bug in 7.10; rather it was a bug in 7.8.

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


More information about the ghc-tickets mailing list