Skip to content

Against space in record updates and record patterns #565

@cjay

Description

@cjay

Currently, Ormolu always seems to format record updates and patterns with a space between the record data constructor or variable and the { like this:
foo {bar} instead of alternatives like foo{ bar } or foo{bar}.

This has the disadvantage that the {} part looks like an additional function parameter when used in function calls or pattern matches in function definitions, which is especially confusing to newbies:
foo a {b} c -- function call: looks like 3 parameters but is actually 2
foo Bar {baz} blerg = ... -- same with pattern match in function definition

Personally, I prefer foo{ bar }. It makes visually clear that the {} part belongs to the preceding identifier, while having superior readability compared to foo{bar}. Side note, it is only one character longer than the current foo {bar}.

If there are good reasons for this design decision, it would be nice to have them collected in the design document, or at least in this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    styleNitpicking and things related to purely visual aspect for formatting.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions