keiki
Safe HaskellNone
LanguageGHC2024

Keiki.Render.Pretty

Description

Pure, domain-readable pretty-printer for keiki's predicate, term, and update syntax trees (HsPred, Term, Update). Produces Text. No solver, no IO. Shared by the Mermaid behavioral renderer (Mermaid) and the sibling edge-inspector / multiline-label renderers.

Two things are deliberately marked rather than invented: applied opaque Haskell functions render as fn(...), and explicit display-opaque literal values render as lit. Ordinary TLit values use their retained Show evidence.

Synopsis

Documentation

indexName :: forall (rs :: [Slot]) r. Index rs r -> String Source #

Recover the slot name an Index points at, by walking SIdx down to the ZIdx and reading its KnownSymbol. No extra class constraint is needed: ZIdx carries the slot's symbol. The ZIdx @s type-application pattern binds the existential symbol directly.

prettyTerm :: forall (rs :: [Slot]) ci (ifs :: [Slot]) r. Term rs ci ifs r -> Text Source #

Render a Term as domain-readable Text. Register reads render by slot name, input-field reads as ctor.field, arithmetic structurally with + - *. Opaque applied functions render fn(...). Ordinary literals use their value's Show instance; explicit opaque literals render as lit.

prettyPred :: forall (rs :: [Slot]) ci. HsPred rs ci -> Text Source #

Render an HsPred guard as domain-readable Text. Boolean structure renders with && || ! and parentheses; PInCtor renders the constructor name; PEq/PCmp render their operand Terms around == <= >=.

prettyUpdate :: forall (rs :: [Slot]) (w :: [Symbol]) ci. Update rs w ci -> Text Source #

Render an Update as domain-readable Text. UKeep renders (keep); USet renders slot := term (the slot name comes from the name-tagged IndexN via indexNName); UCombine joins comma-separated.