Skip to content

show breaks lines at an arbitrary column limit #291

@iitalics

Description

@iitalics

When you use the generated function show it will break lines at ~80 columns, inserting newlines into the returned string:

type t = int list [@@deriving show]
let s = show (List.init 25 succ)
let _ = assert (s = "[1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 14; 15; 16; 17; 18; 19; 20; 21;\n  22; 23; 24; 25]")

This is not desirable since semantically, show does not have any context for how the string will be used so it should not be making assumptions about a column limit.

The reason is that the underlying formatting function Format.asprintf uses preconfigured formatting configuration which sets a max_indent margin.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions