Skip to content

[Poll] Consider changing the default of fsharp_multiline_bracket_style #3200

@nojaf

Description

@nojaf

Hello everyone,

I recently had a conversation about how Fantomas formats records by default (fsharp_multiline_bracket_style = cramped).

There’s a configuration setting for this: fsharp_multiline_bracket_style.

The benefit of the cramped style is that it’s compact and may feel familiar to developers coming from OCaml or Haskell.

let myRecord =
    { Level = 1
      Progress = "foo"
      Bar = "bar"
      Street = "Bakerstreet"
      Number = 42 }

type Range =
    { From: float
      To: float
      FileName: string }

let a =
    [| (1, 2, 3)
       (4, 5, 6)
       (7, 8, 9)
       (10, 11, 12)
       (13, 14, 15)
       (16, 17, 18)
       (19, 20, 21) |]

The main drawback of this style is that it’s harder to manipulate record fields during copy/paste operations.
Indentation can also feel slightly off:

// indent_size = 4
let myRecord =
// Start of { at 4 spaces
    { Level = 1
// Start of record field at 6 spaces
      Progress = "foo"

This breaks what I call the “indentation flow.”
This topic deserves its own discussion, but it’s not the main focus here.

The other available styles (aligned and stroustrup) do not have this issue:

// aligned
let myRecord =
    {
        Level = 1
        Progress = "foo"
        Bar = "bar"
        Street = "Bakerstreet"
        Number = 42
    }

type Range =
    {
        From: float
        To: float
        FileName: string
    }

let a =
    [|
        (1, 2, 3)
        (4, 5, 6)
        (7, 8, 9)
        (10, 11, 12)
        (13, 14, 15)
        (16, 17, 18)
        (19, 20, 21)
    |]

// stroustrup
let myRecord = {
    Level = 1
    Progress = "foo"
    Bar = "bar"
    Street = "Bakerstreet"
    Number = 42
}

type Range = {
    From: float
    To: float
    FileName: string
}

let a = [|
    (1, 2, 3)
    (4, 5, 6)
    (7, 8, 9)
    (10, 11, 12)
    (13, 14, 15)
    (16, 17, 18)
    (19, 20, 21)
|]

These styles make it easier to add or remove record fields, and indentation stays consistent with multiples of the indent_size.

The F# style guide mentions all three of these styles.

So, the key question is:

Should we reconsider the default style?

We (the Fantomas core team) would like to get a sense of how the community feels about this.
We are not promising any changes, but if there is strong community consensus in favour of something else, we will consider it seriously.

This has been the default for many years, so we will not make any changes lightly.

That said, we’d love to hear your preference.
Please react to the first message in this issue with:

  • 👀 if you prefer to keep the current default (cramped)
  • 🎉 if you’d prefer aligned
  • 🚀 if you’d prefer stroustrup

We’ll only count reactions to the first post in this issue.
Reactions or opinions elsewhere will not be included.

//cc @dawedawe @josh-degraw

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions