]> Repositorios git - classgraph.git/commitdiff
Don't show "Right-hand side" for data fam-instances
authorJavier Sagredo <[email protected]>
Thu, 7 May 2026 00:20:31 +0000 (02:20 +0200)
committerJavier Sagredo <[email protected]>
Thu, 7 May 2026 00:20:31 +0000 (02:20 +0200)
GHC's RHS for a @data instance@ is the synthetic R: TyCon (e.g.
@R:CrateInt@), and after the data-family R: rewrite it's the
abstract @FamilyApp Family [args]@ form — structurally equal to the
LHS. Labelling the panel row "Right-hand side: Crate Int" was
misleading because it just repeated what the heading already said.
Replace with a short "Data instance — the right-hand side is a
synthetic GHC-internal data constructor and isn't shown." note for
data fam-instances; type fam-instances keep the real RHS line.

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

index 507a0c32f0c34c4be9633c524236975219654bee..91029216a4bfd7fa2d9ee91700d6792328281b98 100644 (file)
           <dt>Status</dt><dd><em>Use site of an external type family — the equation isn't in this project's dumps, so the right-hand side can't be resolved here.</em></dd>
         </dl>`;
     }
-    const rhs = escape(renderArg(fi.fiRhs, fi.fiTyVars));
     const tvs = fi.fiTyVars.length === 0 ? '<dd><em>none</em></dd>' :
       `<dd><ul>${fi.fiTyVars.map(v =>
         `<li>${escape(v.tvName)}<span style="color:#888"> :: ${escape(v.tvKind)}</span></li>`).join('')}</ul></dd>`;
     const src = renderDefinedAt(fi.fiSrc, fi.fiDefinedIn || fi.fiFamily.qnPackage);
+    // For data fam-instances we *don't* show a "Right-hand side" row.
+    // GHC's representation is the synthetic R: TyCon (`R:CrateInt`),
+    // and after our R: rewrite it's the abstract @FamilyApp Family
+    // [args]@ form — structurally equal to the LHS, so labelling it
+    // "Right-hand side" was actively misleading. Show a brief
+    // explanatory note instead.
+    const rhsEntry = fi.fiIsData
+      ? `<dt>Kind</dt><dd><em>Data instance — the right-hand side is a synthetic GHC-internal data constructor and isn't shown.</em></dd>`
+      : `<dt>Right-hand side</dt><dd>${escape(renderArg(fi.fiRhs, fi.fiTyVars))}</dd>`;
     return `
       <h2>${head}</h2>
       <p class="pkgmod">${escape(fi.fiFamily.qnPackage)} · ${escape(fi.fiFamily.qnModule)}</p>
       <dl>
         ${renderDocSection(fi.fiDoc)}
-        <dt>Right-hand side</dt><dd>${rhs}</dd>
+        ${rhsEntry}
         <dt>Type variables</dt>${tvs}
         <dt>Defined at</dt>${src}
       </dl>`;