From e174401caa10fe2a06534e5b0a9b54237c7f8d76 Mon Sep 17 00:00:00 2001 From: Javier Sagredo Date: Thu, 7 May 2026 02:20:31 +0200 Subject: [PATCH] Don't show "Right-hand side" for data fam-instances MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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) --- data/viewer.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/data/viewer.js b/data/viewer.js index 507a0c3..9102921 100644 --- a/data/viewer.js +++ b/data/viewer.js @@ -1918,17 +1918,25 @@
Status
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.
`; } - const rhs = escape(renderArg(fi.fiRhs, fi.fiTyVars)); const tvs = fi.fiTyVars.length === 0 ? '
none
' : `
    ${fi.fiTyVars.map(v => `
  • ${escape(v.tvName)} :: ${escape(v.tvKind)}
  • `).join('')}
`; 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 + ? `
Kind
Data instance — the right-hand side is a synthetic GHC-internal data constructor and isn't shown.
` + : `
Right-hand side
${escape(renderArg(fi.fiRhs, fi.fiTyVars))}
`; return `

${head}

${escape(fi.fiFamily.qnPackage)} · ${escape(fi.fiFamily.qnModule)}

${renderDocSection(fi.fiDoc)} -
Right-hand side
${rhs}
+ ${rhsEntry}
Type variables
${tvs}
Defined at
${src}
`; -- 2.54.0