Skip to content

Improve deriveAutoReg constraint calculations#3111

Open
leonschoorl wants to merge 4 commits intomasterfrom
fix-deriveAutoReg
Open

Improve deriveAutoReg constraint calculations#3111
leonschoorl wants to merge 4 commits intomasterfrom
fix-deriveAutoReg

Conversation

@leonschoorl
Copy link
Copy Markdown
Member

@leonschoorl leonschoorl commented Dec 19, 2025

This fixes the constraint calculation issues in deriveAutoReg seen in https://clash-lang.discourse.group/t/deriveautoreg-with-superclass-constraints/100

In addition to looking for constraints on AutoReg instances fields,
deriveAutoReg now also looks for constraints on the NFDataX instance of the whole type.

Still TODO:

  • Write a changelog entry (see changelog/README.md)
  • Check copyright notices are up to date in edited files
  • Add a test?

In addition to looking for constraints on AutoReg instances fields,
we now also look for constraints on the NFDataX instance of the whole type.
This isn't strictly necessary.
As GHC will handle the superflous constraints without problems.
But it was cluttering up the documentation.

The previous commit changed the AutoReg instance for a 2-tuple from:
  (AutoReg a, AutoReg b) => AutoReg (a, b)
to:
  (AutoReg a, AutoReg b, NFDataX a, NFDataX b) => AutoReg (a, b)

With this extra filtering step we're back to the original.
@leonschoorl leonschoorl changed the title Fix deriveAutoReg constraint calculations Improve deriveAutoReg constraint calculations Jan 12, 2026
@leonschoorl leonschoorl marked this pull request as ready for review January 12, 2026 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant