</dl>`;
}
+ // Pretty-print a TypeFamilyFlavor as the user would expect to see
+ // it in source: "Open type family", "Closed type family", "Data
+ // family", "Associated type family (member of <parent class>)".
+ // Falls back to whatever the raw tag string is for forwards-
+ // compatibility with future flavours.
+ function renderFlavor(flav) {
+ if (!flav) return '';
+ const tag = typeof flav === 'string' ? flav : (flav.tag || '');
+ switch (tag) {
+ case 'OpenFam': return 'Open type family';
+ case 'ClosedFam': return 'Closed type family';
+ case 'DataFam': return 'Data family';
+ case 'AssocFam': {
+ const parent = flav.contents;
+ const parentName = parent && parent.qnName
+ ? parent.qnName + ' (' + (parent.qnModule || '') + ')'
+ : '';
+ return parentName
+ ? 'Associated type family (member of ' + parentName + ')'
+ : 'Associated type family';
+ }
+ default: return tag || JSON.stringify(flav);
+ }
+ }
+
function renderFamilyPanel(f) {
const tvs = f.tfTyVars
.map(v => `<li>${escape(v.tvName)}<span style="color:#888"> :: ${escape(v.tvKind)}</span></li>`)
.join('');
- const flav = (typeof f.tfFlavor === 'string')
- ? f.tfFlavor : (f.tfFlavor.tag || JSON.stringify(f.tfFlavor));
+ const flav = renderFlavor(f.tfFlavor);
const src = renderDefinedAt(f.tfSrc, f.tfName.qnPackage);
return `
<h2>${escape(f.tfName.qnName)}</h2>
<p class="pkgmod">${escape(f.tfName.qnPackage)} ยท ${escape(f.tfName.qnModule)}</p>
<dl>
${renderDocSection(f.tfDoc)}
- <dt>Flavor</dt><dd>${escape(String(flav))}</dd>
+ <dt>Flavor</dt><dd>${escape(flav)}</dd>
<dt>Type variables</dt><dd><ul>${tvs}</ul></dd>
<dt>Result kind</dt><dd>${escape(f.tfResultKind)}</dd>
<dt>Defined at</dt>${src}