Skip to content
Topaz6.0 · Before release
Download

Search documentation

Specification 6.0 · Not released · Tested product 5.21.3

Use arrow keys to choose a result. Press Enter to open.

Type an API name, diagnostic number, rule, or project topic.

    Library · std.typeset

    TypesetError.InvalidInput

    Invalid measured data or boundary structure.

    TypesetError.InvalidInput(string)
    Receiver
    Not applicable
    Minimum arity
    1
    Maximum arity
    1

    Declaration and parameters

    Link

    Availability

    Included by default: Pending

    Import std.typeset in language mode 5.21.

    The current compiler selects std/typeset.tpz for this language mode. Availability in other released editions and inclusion in each installed distribution are Pending.

    Source evidence

    Receiver

    Parameter constraints

    TypesetError values are returned in Err by the typesetting operations that declare them. InvalidInput carries explanatory text for invalid measured data or boundary structure. InvalidPolicy carries explanatory text for an invalid algorithm configuration.

    The string payload describes a cause. Programs distinguish failure categories by matching the variant rather than comparing library message text. Constructing an error value directly preserves its supplied string.

    NoBreakOpportunities means a nonempty paragraph has no selectable penalty candidate after validation and filtering. It does not mean that the selected cost model searched unsuccessfully.

    NoGreedyPlan means a validated paragraph has selectable candidates but its deterministic greedy baseline cannot reach the final unit. NoPlan means that baseline completed but the selected optimization search found no permitted complete plan.

    A successful empty paragraph has two empty plans and zero candidates under the paragraph contract. It is not a missing-opportunity failure.

    breakParagraph validates policy configuration before measured items. It then checks candidates, builds the greedy plan, and searches for an optimized plan in that order. The first failing stage determines the returned variant.

    The policy stages check geometry, the cost model and grid combination, justification settings, and KnuthPlass settings. Item validation follows source encounter order and checks collected penalty endpoints after the measured units.

    classifyBreaks applies its input and break-policy validation rules. The shared error variants do not impose paragraph validation order on break classification.

    An Err contains no partial ParagraphResult and does not mutate the supplied input. Previously completed argument effects remain completed. A failure while evaluating an argument keeps its ordinary language diagnostic and prevents the typesetting call.

    Result

    Effects

    Failures

    Result and effects

    Link

    Carries explanatory text. Match the variant to distinguish malformed input from a missing plan.

    Why

    Link

    A named failure category lets callers select a recovery without depending on message wording.

    Resolved contracts

    Link

    Related entries

    Link

    std.typeset

    Distinguish invalid data from unavailable plans

    Link
    Ruletopaz.stdlib.contract.typeset-errors.rule

    Distinguish invalid data from unavailable plans

    TypesetError values are returned in Err by the typesetting operations that declare them. InvalidInput carries explanatory text for invalid measured data or boundary structure. InvalidPolicy carries explanatory text for an invalid algorithm configuration.

    The string payload describes a cause. Programs distinguish failure categories by matching the variant rather than comparing library message text. Constructing an error value directly preserves its supplied string.

    NoBreakOpportunities means a nonempty paragraph has no selectable penalty candidate after validation and filtering. It does not mean that the selected cost model searched unsuccessfully.

    NoGreedyPlan means a validated paragraph has selectable candidates but its deterministic greedy baseline cannot reach the final unit. NoPlan means that baseline completed but the selected optimization search found no permitted complete plan.

    A successful empty paragraph has two empty plans and zero candidates under the paragraph contract. It is not a missing-opportunity failure.

    breakParagraph validates policy configuration before measured items. It then checks candidates, builds the greedy plan, and searches for an optimized plan in that order. The first failing stage determines the returned variant.

    The policy stages check geometry, the cost model and grid combination, justification settings, and KnuthPlass settings. Item validation follows source encounter order and checks collected penalty endpoints after the measured units.

    classifyBreaks applies its input and break-policy validation rules. The shared error variants do not impose paragraph validation order on break classification.

    An Err contains no partial ParagraphResult and does not mutate the supplied input. Previously completed argument effects remain completed. A failure while evaluating an argument keeps its ordinary language diagnostic and prevents the typesetting call.

    Why

    Applications can repair malformed data, choose another policy, or report the absence of a plan when these outcomes stay distinct. Named variants provide that decision without relying on diagnostic wording or silently substituting a different algorithm.

    Source evidence

    Preserve explanatory error payloads

    Link
    main.tpzPreserve explanatory error payloadsOpen in Playground
    1. import std.typeset as ts
    2. import std.io
    3. let failures: Array<ts.TypesetError> = [
    4. ts.TypesetError.InvalidInput("measured unit"),
    5. ts.TypesetError.InvalidPolicy("line target")
    6. ]
    7. for failure in (failures) {
    8. match (failure) {
    9. case InvalidInput(message) => io.writeLine("input {message}")
    10. case InvalidPolicy(message) => io.writeLine("policy {message}")
    11. case _ => io.writeLine("unexpected variant")
    12. }
    13. }
    Expected outputexit 0
    input measured unit
    policy line target
    
    $ topaz run main.tpz · target product 5.21.3
    Expected result

    Expected result

    Execution completes. Exit code 0.

    Expected stdout
    1. input measured unit
    2. policy line target
    Source evidence

    Report an invalid paragraph policy before an invalid unit index

    Link
    main.tpzReport an invalid paragraph policy before an invalid unit indexOpen in Playground
    1. import std.typeset as ts
    2. import std.io
    3. let items: Array<ts.Item> = [
    4. ts.Item.BoxItem(ts.Box { unitIndex: 1, text: "a", width: 1pt, trackingAfter: 0pt }),
    5. ts.Item.PenaltyItem(ts.Penalty { unitEnd: 1, width: 0pt, rule: ts.BreakRule.Forced(), kind: ts.BreakKind.ForcedEnd(), flagged: false })
    6. ]
    7. let input = ts.Paragraph {
    8. grid: ts.DistanceGrid.MilliPoint(),
    9. items: items,
    10. geometry: ts.LineGeometry { bodyTarget: 0pt, firstTarget: 0pt, dropCapSpan: 0, dropCapInset: 0pt },
    11. justification: ts.JustificationPolicy {
    12. mode: ts.JustificationMode.Unjustified(), minGapCount: 0,
    13. minLineWidthRatioM: 0, minFinalLineWidthRatioM: None(),
    14. maxAdjustment: 0pt, maxGapAdjustment: 0pt, maxGapRatioR: 0,
    15. latinSpacing: None(), cjkStretchRatio: 0.0
    16. },
    17. costModel: ts.CostModel.FixedPoint(),
    18. knuthPlass: ts.KnuthPlassPolicy { toleranceR: 100000000, linePenalty: 10, fitnessDemerit: 0, flaggedDemerit: 0, finalFlaggedDemerit: 0 }
    19. }
    20. match (ts.breakParagraph(input)) {
    21. case Err(InvalidPolicy(_)) => io.writeLine("InvalidPolicy")
    22. case _ => io.writeLine("unexpected result")
    23. }
    Expected outputexit 0
    InvalidPolicy
    
    $ topaz run main.tpz · target product 5.21.3
    Expected result

    Expected result

    Execution completes. Exit code 0.

    Expected stdout
    1. InvalidPolicy
    Source evidence

    Menu

    Download