Sign in

    quireloom

    Deterministic booklet imposition and fold-order verification in pure MoonBit

    booklet
    imposition
    printing
    Download zip
    Author
    Version
    0.1.0
    License
    Apache-2.0
    Last updated
    12 hours ago
    Downloads
    2

    #Novanke/quireloom

    Binding

    pub(all) enum Binding {
    Left
    Right
    } derive(Eq,
    Debug
    )

    Binding::equal

    fn Binding::equal(Binding, Binding) -> Bool

    Binding::not_equal

    fn Binding::not_equal(x : Binding, y : Binding) -> Bool

    Binding::to_repr

    Duplex

    pub(all) enum Duplex {
    LongEdge
    ShortEdge
    } derive(Eq,
    Debug
    )

    Duplex::equal

    fn Duplex::equal(Duplex, Duplex) -> Bool

    Duplex::not_equal

    fn Duplex::not_equal(x : Duplex, y : Duplex) -> Bool

    Duplex::to_repr

    Face

    pub(all) struct Face {
    left : Slot
    right : Slot
    rotation : Int
    } derive(Eq,
    Debug
    )

    Face::equal

    fn Face::equal(Face, Face) -> Bool

    Face::not_equal

    fn Face::not_equal(x : Face, y : Face) -> Bool

    Face::to_repr

    Layout

    pub(all) struct Layout {
    left : Rect
    right : Rect
    } derive(Eq,
    Debug
    )

    Layout::equal

    fn Layout::equal(Layout, Layout) -> Bool

    Layout::not_equal

    fn Layout::not_equal(x : Layout, y : Layout) -> Bool

    Layout::to_repr

    Paper

    pub(all) struct Paper {
    width : Int
    height : Int
    margin : Int
    gutter : Int
    creep : Int
    } derive(Eq,
    Debug
    )

    All distances are integer millimetres. Creep means an explicit inward shift.

    Paper::equal

    fn Paper::equal(Paper, Paper) -> Bool

    Paper::not_equal

    fn Paper::not_equal(x : Paper, y : Paper) -> Bool

    Paper::to_repr

    Plan

    pub(all) struct Plan {
    page_count : Int
    signature_pages : Int
    binding : Binding
    duplex : Duplex
    sheets : Array[Sheet]
    } derive(Eq,
    Debug
    )

    Plan::equal

    fn Plan::equal(Plan, Plan) -> Bool

    Plan::not_equal

    fn Plan::not_equal(x : Plan, y : Plan) -> Bool

    Plan::to_repr

    PlanError

    pub(all) enum PlanError {
    PageCount
    SignatureSize
    Geometry
    CorruptPlan(String)
    } derive(Eq,
    Debug
    )

    PlanError::equal

    fn PlanError::equal(PlanError, PlanError) -> Bool

    PlanError::not_equal

    fn PlanError::not_equal(x : PlanError, y : PlanError) -> Bool

    Rect

    pub(all) struct Rect {
    x : Int
    y : Int
    width : Int
    height : Int
    } derive(Eq,
    Debug
    )

    Rect::equal

    fn Rect::equal(Rect, Rect) -> Bool

    Rect::not_equal

    fn Rect::not_equal(x : Rect, y : Rect) -> Bool

    Rect::to_repr

    Sheet

    pub(all) struct Sheet {
    signature : Int
    depth : Int
    front : Face
    back : Face
    } derive(Eq,
    Debug
    )

    Sheet::equal

    fn Sheet::equal(Sheet, Sheet) -> Bool

    Sheet::not_equal

    fn Sheet::not_equal(x : Sheet, y : Sheet) -> Bool

    Sheet::to_repr

    Signature

    pub(all) struct Signature {
    index : Int
    start : Int
    pages : Int
    real_pages : Int
    } derive(Eq,
    Debug
    )

    Signature::equal

    fn Signature::equal(Signature, Signature) -> Bool

    Signature::not_equal

    fn Signature::not_equal(x : Signature, y : Signature) -> Bool

    Slot

    pub(all) enum Slot {
    Page(Int)
    Blank
    } derive(Eq,
    Debug
    )

    Slot::equal

    fn Slot::equal(Slot, Slot) -> Bool

    Slot::not_equal

    fn Slot::not_equal(x : Slot, y : Slot) -> Bool

    Slot::to_repr

    csv_report

    fn csv_report(plan : Plan) -> Result[String, PlanError]

    Each row is one face, with empty fields for deliberate blanks.

    impose

    fn impose(pages : Int, maximum : Int) -> Result[Plan, PlanError]

    Sheet order is signature order, then outside to inside.

    impose_with

    fn impose_with(pages : Int, maximum : Int, binding : Binding, duplex : Duplex) -> Result[Plan, PlanError]

    A short-edge back is the complete canonical back rotated by 180 degrees.

    json_report

    fn json_report(plan : Plan) -> Result[String, PlanError]

    Only fixed field names and checked integers enter JSON, so no raw text escapes.

    layout

    fn layout(paper : Paper, depth : Int) -> Result[Layout, PlanError]

    Reject clipping, overlapping panels and unsafe integer arithmetic.

    recover

    fn recover(plan : Plan) -> Result[Array[Slot], PlanError]

    Undo print orientation, then traverse folded leaves from outside to inside. This verifier consumes a supplied plan; it does not regenerate an imposition.

    signatures

    fn signatures(pages : Int, maximum : Int) -> Result[Array[Signature], PlanError]

    Split a book into sequential gatherings, padding only the final one to four.

    svg_proof

    fn svg_proof(plan : Plan, paper : Paper, sheet_index : Int, back : Bool) -> Result[String, PlanError]

    A proof contains page labels and a fold line, not source PDF artwork.

    validate_config

    fn validate_config(pages : Int, signature_pages : Int) -> Result[Unit, PlanError]

    Bounded inputs keep page arithmetic exact on every backend.

    verify

    fn verify(plan : Plan) -> Result[Unit, PlanError]

    Require exact reading order, including every final blank.

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io