Module

Sigil

Package
purescript-sigil
Repository
afcondon/purescript-sigil

purescript-sigil — Typographic rendering for type signatures (HTML + SVG).

Re-exports the public API.

Re-exports from Sigil.Color

#defaultEffectNames Source

#assignVarColors Source

assignVarColors :: Array String -> Map String String

Assign colors to type variables. Earlier variables get earlier palette slots.

Re-exports from Sigil.Html

#renderTypeSynonymInto Source

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

Render a type synonym into a container element.

#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.

#renderSignetInto Source

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

Render a signet into a container element.

#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.

#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.

#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).

#renderSigletInto Source

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

Render a siglet into a container element.

#renderSiglet Source

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

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

#renderForeignImportInto Source

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

Render a foreign import into a container element.

#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.

#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.

#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.

#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.

#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.

#renderBodyInto Source

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

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

#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.

#peelSignature Source

peelSignature :: RenderType -> PeeledSig

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

#escapeHtml Source

escapeHtml :: String -> String

Escape HTML special characters.

Re-exports from Sigil.Parse

#parseToRenderType Source

parseToRenderType :: String -> Maybe RenderType

Parse a type signature string to RenderType. Sanitizes loader artifacts (e.g. trailing comma before row variable) before parsing.

#extractCtorRenderTypes Source

extractCtorRenderTypes :: String -> Array RenderType

Extract constructor argument types as RenderType values. Constructor sigs look like "a -> b -> MyType a b" — returns [TVar "a", TVar "b"].

#extractCtorArgs Source

extractCtorArgs :: String -> Array String

Extract constructor argument types from a constructor signature string. Constructor sigs look like "a -> b -> MyType a b" — returns ["a", "b"] as text.

#elideAST Source

elideAST :: RenderType -> RenderType

Prepare AST for siglet rendering. Preserves record/row structure (with elided field types) so the siglet renderer can show { ○ ○ ○ } notation. Forall, constraints, and parens are kept. Normalizes Record (row) application to TRecord.

Re-exports from Sigil.Svg.Attrs

#SvgPrimitive Source

type SvgPrimitive = { attrs :: Array { key :: String, value :: String }, children :: Array LayoutNode, tag :: String, textContent :: Maybe String }

Re-exports from Sigil.Svg.Emit

#renderSignatureIntoSvg Source

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

Render a signature into a DOM element selected by CSS selector.

#renderClassDeclIntoSvg Source

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

Render a class definition into a DOM element selected by CSS selector.

#renderAdtIntoSvg Source

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

Render an ADT into a DOM element selected by CSS selector.

#emitNode Source

emitNode :: LayoutNode -> Effect Element

Emit a single LayoutNode to a DOM element.

#emit Source

emit :: LayoutNode -> Dimensions -> Effect Element

Emit a layout tree as a detached SVG element with the given dimensions.

Re-exports from Sigil.Svg.Layout.ADT

#layoutADT Source

layoutADT :: { constructors :: Array { args :: Array RenderType, name :: String }, keyword :: Maybe String, name :: String, typeParams :: Array String } -> { dimensions :: Dimensions, layout :: LayoutNode }

Lay out a data type with constructor branches.

Re-exports from Sigil.Svg.Layout.ClassDef

#layoutClassDef Source

layoutClassDef :: { methods :: Array { ast :: Maybe RenderType, name :: String }, name :: String, superclasses :: Array SuperclassInfo, typeParams :: Array String } -> { dimensions :: Dimensions, layout :: LayoutNode }

Lay out a type class definition.

Re-exports from Sigil.Svg.Layout.Siglet

#layoutSiglet Source

layoutSiglet :: { ast :: RenderType, maxHeight :: Number, maxWidth :: Number } -> Maybe { layout :: LayoutNode, scaledHeight :: Number, scaledWidth :: Number }

Lay out a siglet (elided miniature type signature). TCon names render as small circles; TVar pills keep colors. Layout mirrors the full-size sigil: constraint pile above, body middle, forall row below. Returns Nothing if the type can't fit.

Re-exports from Sigil.Svg.Layout.Signature

#layoutSignature Source

layoutSignature :: { ast :: RenderType, className :: Maybe String, name :: String, sig :: String, typeParams :: Array String } -> { dimensions :: Dimensions, layout :: LayoutNode }

Lay out a value/type-synonym signature.

Re-exports from Sigil.Svg.Layout.Sparkline

#layoutSparkline Source

layoutSparkline :: { ast :: RenderType, maxHeight :: Number, maxScale :: Maybe Number, maxWidth :: Number } -> Maybe { layout :: LayoutNode, scaledHeight :: Number, scaledWidth :: Number }

Lay out a sparkline miniature.

Re-exports from Sigil.Svg.Measure

#RenderContext Source

type RenderContext = { charWidth :: Number, fontSize :: Number, lineHeight :: Number, padding :: { x :: Number, y :: Number }, sigletMode :: Boolean, varColors :: Map String String }

Rendering context threaded through layout functions.

#measure Source

measure :: RenderContext -> RenderType -> Dimensions

Measure a RenderType node's dimensions.

Re-exports from Sigil.Svg.Types

#RenderResult Source

type RenderResult = { nodes :: Array LayoutNode, width :: Number }

Internal result from node-level layout: positioned nodes + consumed width.

#LayoutNode Source

data LayoutNode

A positioned SVG primitive. The entire layout pipeline produces these; only Emit touches the DOM.

Constructors

#Dimensions Source

type Dimensions = { height :: Number, width :: Number }

Re-exports from Sigil.Text

#renderTypeToText Source

renderTypeToText :: RenderType -> String

Render a RenderType back to plain text.

#fieldVars Source

fieldVars :: Array RowField -> Maybe String -> Set String

Collect type variables from record/row fields.

#collectTypeVars Source

collectTypeVars :: RenderType -> Set String

Collect all type variable names from a RenderType.

#collectForallVars Source

collectForallVars :: RenderType -> Array String

Collect all forall-quantified variable names (including nested foralls).

#collectArrowParams Source

collectArrowParams :: RenderType -> Array RenderType

Collect all params of an arrow chain (including return type at end).

Re-exports from Sigil.Types

#SuperclassInfo Source

type SuperclassInfo = { methods :: Array { ast :: Maybe RenderType, name :: String }, name :: String }

Superclass info for class definition rendering. Contains the class name and its required methods with optional parsed types.

#RowField Source

type RowField = { label :: String, value :: RenderType }

#Constraint Source

type Constraint = { args :: Array RenderType, className :: String }