Opened 12 months ago

Last modified 12 months ago

#15759 new bug

GHC doesn't use fixity in type instances

Reported by: goldfire Owned by:
Priority: normal Milestone:
Component: Compiler Version: 8.6.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: #11307 Differential Rev(s):
Wiki Page:


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.

Change History (1)

comment:1 Changed 12 months ago by RyanGlScott

See also #11307.

Note: See TracTickets for help on using tickets.