Opened 7 years ago

Closed 7 years ago

#6064 closed feature request (invalid)

InstanceD declaration does not allow for explicit TyVarBndrs

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


The definition of InstanceD does not allow for explicitly-kinded type variables. Though it is possible to use SigT to give kinds in places, GHC currently does not allow undeclared kind variables to appear there.

I propose changing the definition of InstanceD to be as follows:

type Dec =
  | InstanceD [TyVarBndr] Cxt Type [Dec]

Attachments (1)

patches.tar.gz (2.5 KB) - added by goldfire 7 years ago.

Download all attachments as: .zip

Change History (4)

Changed 7 years ago by goldfire

Attachment: patches.tar.gz added

comment:1 Changed 7 years ago by goldfire

Owner: set to goldfire

I've attached a patch that does the above. This is a breaking change, so I'm not convinced it should be made, but I would like an alternative to using kind variables in instance declarations with TH. (The other route would be to allow the use of undeclared kind variables in the head of an instance declaration.)

One particular potential annoyance with this change is that all type variables used in an instance declaration produced in TH are required to be declared in the TyVarBndrs. It is conceivable to relax this restriction by checking for the declarations and inferring them if they are not there, but this idea is not implemented in the patch because it feels, well, patchy.

I have not fully validated nor updated the test cases with respect to this change, but would be happy to do so if the change is desired. Please let me know if you would like this!

comment:2 Changed 7 years ago by goldfire

I have now come across a case in my code where I would more legitimately like to use undeclared kind variables in an instance declaration. I have made a bug report (#6081) to that effect. If that bug is resolved, then this feature request should be dropped, as current capabilities in TH will be sufficient for what I wish to express.

comment:3 Changed 7 years ago by simonpj

difficulty: Unknown
Resolution: invalid
Status: newclosed

OK #6081 is fixed, so I'll close this ticket. Reopen if needed.

Note: See TracTickets for help on using tickets.