Skip to content

Fix type-family reduction over data-family representations (copy #3549) - #3579

Closed
mergify[bot] wants to merge 1 commit into
1.10from
mergify/copy/1.10/pr-3549
Closed

mergify[bot] wants to merge 1 commit into
1.10from
mergify/copy/1.10/pr-3549

Conversation

@mergify

@mergify mergify Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

GHC introduces internal representation constructors for data-family instances. ghc2core reduces concrete family applications to these representations, losing the source family form needed for later type-family matching. So when you have:

data family Tagged (label :: k) :: Type
data instance Tagged (label :: Bool)

type family Width (a :: Type) :: Nat
type instance Width (Tagged label) = 8

Unsigned (Width a)

Unsigned (Width (Tagged 'True)) gets rewritten to Unsigned (Width (R:TaggedBoollabel 'True)) during translation and specialization. GHC records this through a coercion axion, but Clash loses that information.

This PR fixes this by adding tyConFamilyInst :: !(Maybe ([TyVar], Type)) to AlgTyCon. This records the original data-family application, which is then used during normalization to match the type-family equation.

Still TODO:

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

This is an automatic copy of pull request #3549 done by [Mergify](https://mergify.com).

Retain the source family application on GHC representation constructors so
family matching can recover fixed kinds and structured indices. Support
higher-kinded representations through eta reduction and preserve newtype-
family identity during specialization.

(cherry picked from commit 88bf4fe)
@rowanG077

Copy link
Copy Markdown
Member

Next release will be major so closing

@rowanG077 rowanG077 closed this Dec 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant