Literal

Literal :: # (opaque)

Checked source conversions for quoted values and imported text.

Use Literal.require in a top-level declaration to make a checked imported file fail compilation when its contents are invalid. Dynamic inputs should keep their Try result: calling require at runtime can crash at runtime.

require : Try(a, [BadQuotedBytes(Str)]) -> a

Unwrap a checked conversion, or fail with its explanation. A demanded top-level call runs during compilation.

error : ErrorProps -> [BadQuotedBytes(Str)]

Build a simple compiler quotation error without inventing coordinates.

position : Str, U64 -> { line : U64, column : U64 }

Convert a UTF-8 byte offset to a one-based line and byte column. CRLF, CR, and LF each end one line; offsets past the end are clamped.

ErrorProps

:= {
    name : Str ?? "<literal>",
    format : Str,
    message : Str,
    line : U64 ?? 0,
    column : U64 ?? 0,
}

The available location and explanation of a checked conversion failure. Zero line or column means that coordinate is unavailable.