ocamlformat
ocamlformat copied to clipboard
Feature request: compact lists for really short values
Hi all,
I have this function to format timestamps to dates that got ocamlformat'ed. To me, it seems a bit silly that the months lists gets "expanded" whilst the days list is on a single line. Maybe the heuristic that splits the list on multiple lines could be amended if the values are like, really short in textual representation? I know that's adding more corner-cases, but it could make sense.
let output_generated_by oc binary =
let t = now () in
let months =
[|
"Jan";
"Feb";
"Mar";
"Apr";
"May";
"Jun";
"Jul";
"Aug";
"Sep";
"Oct";
"Nov";
"Dec";
|]
in
let days = [| "Sun"; "Mon"; "Tue"; "Wed"; "Thu"; "Fri"; "Sat" |] in
let time = Unix.gmtime t in
let date =
Printf.sprintf "%s, %d %s %d %02d:%02d:%02d GMT" days.(time.Unix.tm_wday)
time.Unix.tm_mday months.(time.Unix.tm_mon) (time.Unix.tm_year + 1900)
time.Unix.tm_hour time.Unix.tm_min time.Unix.tm_sec
in
I think something like #1916 would fit