marianoguerra/shrubbery/write does not have a README file

    Style

    pub(all) enum Style {
    Flat
    Pretty
    Armoured
    PreferMultiline
    } derive(Eq)

    How the output should be laid out.

    bytes_to_string

    fn bytes_to_string(b : Bytes) -> String

    Racket's write for a byte string.

    Octal for anything not printable, and padded to three digits only when the next character is an octal digit -- #"\0001" is byte zero then 1, which #"\01" would not be.

    double_to_string

    fn double_to_string(d : Double) -> String

    Racket's write for a flonum.

    MoonBit's own to_string already produces the shortest round-tripping digits, and agrees with Racket on every value in the corpus. What it does NOT agree on is presentation: Racket forces a .0 on an integral value, switches to exponent notation outside [1e-4, 1e14), and writes the exponent's sign. So the digits are taken from MoonBit and laid out again here.

    string_to_string

    fn string_to_string(s : String) -> String

    Racket's write for a string.

    Named escapes where there is one, \uXXXX for the other non-printing characters, and everything else as itself -- including non-ASCII, which Racket does not escape.

    to_doc

    The layout document for a shrubbery, before a width is chosen.

    Exposed because the document is the interesting object: it describes every legal layout at once, and a consumer with its own renderer -- or its own idea of what fits -- can take it from here.

    write

    fn write(node :
    Node
    , style? : Style, width? : Int?) -> String

    Write a shrubbery.

    The contract is round-tripping: reading the output back with parse produces the same tree. width applies to the pretty styles; None there means "never break a line that could be one", and Some(0) means "break every line that could be broken".

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io