Skip to content

GHC doesn't use fixity in type instances

If I say

data a * b
infixl 7 *

type family a + b
infixl 6 +

type instance Int * Bool + Double = Float

(with -XNoStarIsType -- * is not the issue here)

I get

    • Illegal family instance for ‘*’
        (* is not an indexed type family)
    • In the type instance declaration for ‘*’

But that's wrong. The * should bind tighter than the +, meaning this is an instance for +, not *. This also fails for closed type families:

data a * b
infixl 7 *

type family a + b where
  Int * Bool + Double = Float
infixl 6 +

Interestingly, a class instance works here.

This did not bite me "in the wild", but came up while reading the GHC source code. Still, it is a real bug.

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