Skip to content

Formatting guidelines missing example for match #1079

Open
@ebblake

Description

@ebblake

https://ocaml.org/learn/tutorials/guidelines.html has several recommendations on formatting match patterns, but notably lacks any guidance on the following: when using more than one pattern that both share the same ->, should the second | be indented in relation to the first (to make it obvious that the first lacks ->) or should the | be aligned?
Visually, this is the difference between:

List.iter (
  function
  | A -> x
  | B
  | C -> y
  | D -> z
) list

and:

List.iter (
  function
  | A -> x
  | B
    | C -> y
  | D -> z
) list

emacs-tuareg-2.0.10-5.fc29.noarch, as shipped on Fedora, favors indentation of the secondary patterns (the latter style), although that gets in my way when editing a project that favors the style of always aligning the | (the first style). If the style guide were to state a preference for one way or the other, then the tuareg defaults could match that style (whether or not tuareg also adds a user customization to make it easier to change between the two styles).

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