package wax-lib
All checked builds passInstall
dune-project
Dependency
Authors
Maintainers
Sources
sha256=cc19989d0db930d9300d7356c8f127309424a82767dd3c91ffd19a0bfd20e3a6
sha512=14ff9219dc6c4e8855c3cb895bd1af6fd81d1c521afefe1e7f69208a2e37abc7ec0946f188198a26780aa405fd43a526b938158334a019f7a5d991d8efc437c3
doc/wax-lib.utils/Wax_utils/Message/index.html
Module Wax_utils.MessageSource
A structured diagnostic message: prose that reflows at the target width, plus styled/quoted atoms and escape-hatch fragments that render an AST fragment (a type, an instruction) through the shared pretty-printer.
A message is a data value, rendered late: the theme (colour) and width are supplied only when it is emitted, so the same message renders to a themed terminal (colour, wrapped), or is flattened to a plain single-line string for the JSON / short output formats.
An emphasized atom (ident, code, and the typ combinators built on raw) is shown in its colour when the theme is coloured, and wrapped in '…' when it is not: JSON/short (always uncoloured) are therefore always quoted, while an interactive terminal is coloured and unquoted. Plain prose (text) is never quoted or styled; constants are styled but never quoted.
Prose. Splits on spaces into words joined by soft breaks, so it reflows at the render width; an embedded newline is a hard break. Runs of spaces (including leading/trailing ones) become a single soft break, so fragments joined with (^^) can carry their own separating space.
An emphasized source identifier: coloured Identifier when the theme is coloured, else quoted '…'.
An emphasized inline code token (an instruction, an operator, a literal snippet): coloured Keyword when the theme is coloured, else quoted.
An emphasized type name given as a string (e.g. i32): coloured Type when the theme is coloured, else quoted. The string-level analogue of a rendered type.
One unbreakable styled atom, never quoted.
uint64 n renders n as an unsigned 64-bit integer, so a value with the high bit set prints as its magnitude rather than a negative number.
The escape hatch: run an imperative callback against the render-time styled printer (already carrying the diagnostic's theme and width). The typ combinators of the Wax typer and the Wasm validator are built on this, so they can plug the Output type printers in without lib-utils depending on them.
Lay the argument out as a keep-together box (indented when broken); used to wrap a rendered type so it does not reflow word-by-word.
"a, b or c" — join with commas and conj (default "or") before the last item. Used for did-you-mean lists.
Emit t into the given printer using theme, as a greedy fill box that reflows at the enclosing layout's width.
Render at effectively-infinite width with Colors.no_color, returning a flat, ANSI-free string. Used for the JSON and short output formats.