seenNodes.add(id);
const known = familyById.get(id);
const isData = isDataFamily(known);
+ // Mirror Render.hs's familyNodeLabel: include the family's
+ // tyvars in the label when known, then add `\n(data)` on a new
+ // line for data families. The whole-node italic styling for
+ // data families lives in the cytoscape stylesheet (cytoscape
+ // can't style only one line of a label).
+ const head = (known && known.tfTyVars && known.tfTyVars.length > 0)
+ ? qn.qnName + ' ' + known.tfTyVars.map(tv => tv.tvName).join(' ')
+ : qn.qnName;
+ const label = head + (isData ? '\n(data)' : '');
els.push({ group: 'nodes', data: {
id,
- label: qn.qnName + (isData ? ' (data)' : ''),
+ label,
kind: 'family',
external: !known,
isData: !!isData,
const famNodeId = qid(fam.tfName);
seenNodes.add(famNodeId);
const focusedIsData = isDataFamily(fam);
+ const focusedHead = (fam.tfTyVars && fam.tfTyVars.length > 0)
+ ? fam.tfName.qnName + ' ' + fam.tfTyVars.map(tv => tv.tvName).join(' ')
+ : fam.tfName.qnName;
els.push({ group: 'nodes', data: {
id: famNodeId,
- label: fam.tfName.qnName + (focusedIsData ? ' (data)' : ''),
+ label: focusedHead + (focusedIsData ? '\n(data)' : ''),
kind: 'family',
focused: true,
isData: !!focusedIsData,
color: '#3f2d05',
shape: 'diamond',
height: 'label',
+ // Honour explicit \n in labels — used by the data-family
+ // suffix that goes on its own line.
+ 'text-wrap': 'wrap',
+ },
+ },
+ // Data families specifically — italicise the whole label so the
+ // "(data)" line on the second row reads as a typographic cue.
+ // Cytoscape can't style only one line of a label, so the family
+ // name gets italicised too; that's fine, it's a consistent
+ // visual signal "this family carries data, not types".
+ {
+ selector: 'node[kind = "family"][?isData]',
+ style: {
+ 'font-style': 'italic',
},
},
// External class node (instance view)
| f <- pdTypeFamilies pd
]
+ -- Family node label: family name + its tyvars (e.g. @BftDSIGN c@),
+ -- with @(data)@ on its own line for data families. The viewer's
+ -- cytoscape rule for @node[kind = "family"][?isData]@ italicises
+ -- the whole label — cytoscape can't style only one line, so we
+ -- accept whole-node italic as the visual cue for "data family".
familyNodeLabel f =
- qnName (tfName f) <> if isDataFamily f then " (data)" else ""
+ let head = case tfTyVars f of
+ [] -> qnName (tfName f)
+ tvs -> qnName (tfName f) <> " "
+ <> T.intercalate " " (map tvName tvs)
+ in head <> if isDataFamily f then "\n(data)" else ""
isDataFamily f = case tfFlavor f of
DataFam -> True