Module

Sigil.Html

Package
purescript-sigil
Repository
afcondon/purescript-sigil

HTML string rendering of type signatures with semantic markup.

Maps PureScript type concepts to semantic HTML elements: TVar → <var> (mathematical variable) TCon → <code> (type constructor / identifier) TArrow → <ol> (ordered parameter list) TRecord → <dl> (definition list: field → type) TForall → <var> (quantified variables) Constraint → <em> (qualifying emphasis) separators → <small> (::, →, ., parens — decorative punctuation) name → <dfn> (term being defined)

Visual appearance is entirely CSS-driven, enabling alternate renderings of the same semantic document.

#renderSignature Source

renderSignature :: { ast :: RenderType, className :: Maybe String, name :: String, typeParams :: Array String } -> String

Render a full-size type signature to an HTML string. Uses Swiss typographic layout: preamble (∀ left, constraints right), declaration (name ::), body (indented with left rule).

#renderBody Source

renderBody :: { ast :: RenderType } -> String

Render the sigil body only (no name header, no ::) to HTML. Used for inline rendering in value cells when there's enough space. Still shows preamble (quantifier + constraints) if present.

#renderSiglet Source

renderSiglet :: { ast :: RenderType } -> String

Render a siglet (miniature signature) to HTML. Constrained type variables get pill style; unconstrained get colored text.

#renderSignet Source

renderSignet :: { ast :: RenderType } -> String

Render a signet (dots with rotated identifier labels) to HTML. Same dot layout as the siglet, but each dot has a 45-degree rotated label beneath it showing the type identifier name.

#renderDataDecl Source

renderDataDecl :: { constructors :: Array { args :: Array RenderType, name :: String }, keyword :: Maybe String, name :: String, typeParams :: Array String } -> String

Render a data/newtype declaration to an HTML string. Shows header (keyword + name + type params), then constructor branches in a rail layout, or an opaque indicator if no constructors.

#renderClassDecl Source

renderClassDecl :: { methods :: Array { ast :: Maybe RenderType, name :: String }, name :: String, superclasses :: Array SuperclassInfo, typeParams :: Array String } -> String

Render a type class definition to an HTML string. Shows header (class + name + type params), superclass row, own methods, and inherited methods grouped by superclass.

#renderTypeSynonym Source

renderTypeSynonym :: { body :: RenderType, name :: String, typeParams :: Array String } -> String

Render a type synonym to an HTML string. Shows header (type + name + type params), then = body.

#renderForeignImport Source

renderForeignImport :: { ast :: RenderType, name :: String } -> String

Render a foreign import to an HTML string. Shows header (foreign import + name), then :: body with preamble.

#renderSignatureInto Source

renderSignatureInto :: String -> { ast :: RenderType, className :: Maybe String, name :: String, typeParams :: Array String } -> Effect Unit

Render a full-size signature into a container element.

#renderBodyInto Source

renderBodyInto :: String -> { ast :: RenderType } -> Effect Unit

Render a sigil body (no header) into a container element.

#renderSigletInto Source

renderSigletInto :: String -> { ast :: RenderType } -> Effect Unit

Render a siglet into a container element.

#renderSignetInto Source

renderSignetInto :: String -> { ast :: RenderType } -> Effect Unit

Render a signet into a container element.

#renderDataDeclInto Source

renderDataDeclInto :: String -> { constructors :: Array { args :: Array RenderType, name :: String }, keyword :: Maybe String, name :: String, typeParams :: Array String } -> Effect Unit

Render a data declaration into a container element.

#renderClassDeclInto Source

renderClassDeclInto :: String -> { methods :: Array { ast :: Maybe RenderType, name :: String }, name :: String, superclasses :: Array SuperclassInfo, typeParams :: Array String } -> Effect Unit

Render a class declaration into a container element.

#renderTypeSynonymInto Source

renderTypeSynonymInto :: String -> { body :: RenderType, name :: String, typeParams :: Array String } -> Effect Unit

Render a type synonym into a container element.

#renderForeignImportInto Source

renderForeignImportInto :: String -> { ast :: RenderType, name :: String } -> Effect Unit

Render a foreign import into a container element.

#peelSignature Source

peelSignature :: RenderType -> PeeledSig

Peel outermost forall quantifiers and constraints from the AST. Nested foralls/constraints (rank-N, inside parens) are left intact.

#PeeledSig Source

type PeeledSig = { body :: RenderType, constraints :: Array Constraint, forallVars :: Array String }

Peeled signature: outermost forall/constraints separated from bare body.

#escapeHtml Source

escapeHtml :: String -> String

Escape HTML special characters.