Skip to content

GHC rejects typeclass with associated type

In GHC 7.8.4, the following code is legal:

{-# LANGUAGE TypeFamilies, FlexibleContexts #-}
    
class FiniteGrid g where
  type Size s
  size :: g -> Size g
  maxPossibleDistance :: g -> Int

But with GHC 7.10.1, it no longer compiles. The error message is:

The associated type ‘Size’
mentions none of the type or kind variables of the class ‘FiniteGrid g’
In the class declaration for ‘FiniteGrid’

I didn't see any mention of this in the migration guide, but perhaps there's another pragma I need to enable. I thought this might be related to #10020 (closed), but that bug is apparently fixed in GHC 7.10.1.

Trac metadata
Trac field Value
Version 7.10.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Edited by mhwombat
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information