Skip to content

Type synonyms in class associated types behave strangely

{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TypeFamilies #-}

type Syn a = Associated a

class Eq (Associated a) => Foo a where
    type Associated a :: *
    foo :: a -> Syn a -> Bool

instance Foo () where
    type Associated () = Int
    foo _ x = x == x

In 7.6.3 and 7.8.1-rc2, this file compiles. In 7.8.1 release, GHC produces this error:

    No instance for (Eq (Syn ())) arising from a use of ‘==’
    In the expression: x == x
    In an equation for ‘foo’: foo _ x = x == x
    In the instance declaration for ‘Foo ()’

even though there is an Eq instance for Associated (), and Syn is just a type synonym.

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