Skip to content

Minimize vertical space for single-constructor records #425

@neongreen

Description

@neongreen

The current style (A) for records is:

data Foo
  = Foo
      { bar :: Bar,
        baz :: Baz
      }

I propose the following style (B) for single-constructor records:

data Foo = Foo
  { bar :: Bar,
    baz :: Baz
  }

Pros

  • The most common style, according to Hackage grep.

  • One-constructor records seem to stay one-constructor records so git diffs don't get worse. (Not sure about this one. Feedback welcome.)

  • Slightly better use of horizontal space.

  • Much better use of vertical space for data-heavy modules – important for people who split their screens horizontally instead of vertically.

Cons

  • Still, some diffs are inevitable. Especially annoying when the fields were heavily commented and you have to rewrap the comments.

Unresolved questions

  • Should (A) be reformatted into (B)? "Yes" seems like a good answer, but it would be slightly unfortunate if it was impossible to break a data ReallyReallyReallyReallyLongName = ReallyReallyReallyReallyLongName ... even when requested by the programmerr.

Metadata

Metadata

Assignees

Labels

awaiting-prIssues that users should solve themselves and open a PR.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