]> Repositorios git - classgraph.git/commit
Extract data-family RHS constructors and show them in the viewer
authorJavier Sagredo <[email protected]>
Thu, 7 May 2026 00:32:36 +0000 (02:32 +0200)
committerJavier Sagredo <[email protected]>
Thu, 7 May 2026 00:32:36 +0000 (02:32 +0200)
commit37d3b89e2aade5b2c24c12118e41b6f1c44637ec
tree6e0613dea4fea1accb43b034639ca436adbae6eb
parent4c9c19468588ade1cb323b2d951a4d452257943b
Extract data-family RHS constructors and show them in the viewer

Adds a DataConInfo record (dcName + dcArgs + dcFieldLabels) and a
fiDataCons :: [DataConInfo] field on FamInstInfo. Schema/JSON
encoding is backwards-compatible: missing fiDataCons defaults to [].

Extract.hs's extractFamInst now walks the rep TyCon's
tyConDataCons (pulled directly out of the DataFamilyInst flavour
constructor — famInstTyCon turned out to be the family TyCon, not
the rep, on at least 9.14.1) and turns each DataCon into a
DataConInfo. The data constructor's arg types are extracted with
the fam-instance's tyvars in scope, so positional TyVarRefs resolve
to the right fiTyVars entries.

Viewer:
* renderFamInstHead now shows `Family args = Con1 t1 t2 | Con2 …`
  for data fam-instances (record syntax: `Con { f1 :: t1, f2 :: t2 }`).
* The fam-instance side panel grows a Constructors entry listing
  each data constructor with its fields.

Demo: the existing Crate Int / Crate Bool / Crate [a] data
fam-instances now render with their CrateInt / CrateBool / CrateList
constructors visible.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
data/viewer.css
data/viewer.js
src/Classgraph/Extract.hs
src/Classgraph/Schema.hs