From: Javier Sagredo Date: Thu, 7 May 2026 00:43:54 +0000 (+0200) Subject: Show constructor names in family-view data fam-instance rows too X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=b9b981bd4f7eef441dbd1e568406f16d51987c98;p=classgraph.git Show constructor names in family-view data fam-instance rows too The family view (drilling into a family directly) had its own fam-instance label code path that bypassed renderFamInstHead, so data fam-instance rows showed only their args (no constructor names). Mirror the renderFamInstHead behaviour: append `= ConA | ConB` for data fam-instances. The family name itself stays implicit (it's already at the top of the family view). Co-Authored-By: Claude Opus 4.7 (1M context) --- diff --git a/data/viewer.js b/data/viewer.js index 5cc7e36..362c98c 100644 --- a/data/viewer.js +++ b/data/viewer.js @@ -1095,9 +1095,20 @@ const fiNodeId = 'faminst:' + fi._idx; seenNodes.add(fiNodeId); const args = renderArgsCompact(fi.fiArgs, fi.fiTyVars); - const label = fi.fiIsData - ? (args || '') - : args + ' = ' + renderArg(fi.fiRhs, fi.fiTyVars); + const lhs = args || ''; + let label; + if (fi.fiIsData) { + // In the family view the family name is already shown at the + // top of the graph, so each row only needs `args = Cons`. We + // *do* want the constructor names here, the same way the + // instance view's renderFamInstHead does — just don't repeat + // the family name. + const dcs = fi.fiDataCons || []; + const cons = dcs.map(dc => dc.dcName || '?').join(' | '); + label = cons ? lhs + ' = ' + cons : lhs; + } else { + label = lhs + ' = ' + renderArg(fi.fiRhs, fi.fiTyVars); + } els.push({ group: 'nodes', data: { id: fiNodeId, label,