Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#13747 closed bug (fixed)

Can't use 'instance' keyword in associated type family instance

Reported by: nh2 Owned by: erdeszt
Priority: normal Milestone: 8.4.1
Component: Compiler Version: 8.0.2
Keywords: newcomer Cc: nh2
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect error/warning at compile-time Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D3673
Wiki Page:


The manual on type families says:

When an associated data or type synonym family instance is declared within a type class instance, we (optionally) may drop the instance keyword in the family instance"

But that doesn't work for me.


class Myclass a where
  type family MyFamily a :: *

then the code

instance Myclass Mytype where
  type instance MyFamily Mytype = Int

doesn't compile but

instance Myclass Mytype where
  type          MyFamily Mytype = Int

I'd expect to be able to use the instance keyword here.

I'd prefer this to be treated as an implementation bug instead of a doc bug, because I think it can be useful to be explicit for the ease of reading (and it work works the same way for class declaration, as the example also demonstrates).

Change History (5)

comment:1 Changed 2 years ago by RyanGlScott

Keywords: newcomer added

This sounds reasonable to me.

comment:2 Changed 2 years ago by erdeszt

Differential Rev(s): Phab:D3673
Owner: set to erdeszt

comment:3 Changed 2 years ago by Ben Gamari <ben@…>

In 007f255/ghc:

Allow optional instance keyword in associated type family instances

Add the missing branch for parsing the optional 'instance' keyword
in associated type family instance declarations.

Fixes #13747

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: simonpj, RyanGlScott, rwbarton, thomie, mpickering

Differential Revision:

comment:4 Changed 2 years ago by bgamari

Milestone: 8.4.1
Resolution: fixed
Status: newclosed

Thanks erdeszt!

comment:5 Changed 2 years ago by nh2

Indeed, thanks a lot!

Come to Zurich, show me this ticket and I owe you a beverage of your choice.

Note: See TracTickets for help on using tickets.