Skip to content

Formatter breaks let f: type a. ... = headers when the body spans several lines #9070

Description

@cknitt

The formatter breaks the header of a binding with locally abstract types whenever the body spans several lines, even when the header fits on one line:

let rec eval: type a. expr<a> => a = e =>
  switch e {
  | Int(n) => n
  | Bool(b) => b
  }

is formatted as

let rec eval:
  type a. expr<a> => a =
  e =>
    switch e {
    | Int(n) => n
    | Bool(b) => b
    }

This is the usual way to write a function over a GADT, so every such function gets the three-line header and an extra indentation level. print_value_binding in res_printer.ml puts the header and the body in one group, so a line break in the body breaks every soft line of the header too. The current layout is recorded in tests/syntax_tests/data/printer/expr/expected/newtype.res.txt.

Expected: the header stays on one line when it fits, and the body is laid out as for any other let.

Activity

  1. added theissue type on Oct 27, 2026
  2. added a commit that references this issue on Oct 28, 2026
    fe33a6f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions