Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve formatting of single-constructor types and records #2342

Merged

Conversation

janmasrovira
Copy link
Collaborator

The rules implemented in this pr are as follows.

  1. If a type definition has only one constructor, no pipe is added. The constructor is printed in the same line if it fits.
  2. If a constructor is a record with a single field, the field is printed in the same line if it fits. If the constructor has multiple fields, they are printed aligned and indented after a line break.

Examples:

type T := constructT : T;

type T-wrapper := mkWrapper {unwrap : T};

type EnumRecord :=
  | --- doc for C1
    C1 {
      c1a : T;
      c1b : T
    }
  | C2 {
      c2a : T;
      c2b : T
    };

@janmasrovira janmasrovira self-assigned this Sep 5, 2023
@janmasrovira janmasrovira linked an issue Sep 5, 2023 that may be closed by this pull request
@janmasrovira janmasrovira marked this pull request as ready for review September 5, 2023 23:30
@janmasrovira janmasrovira force-pushed the 2331-dont-add-a-pipe-when-there-is-only-one-constructor branch from a7f9e65 to 84eaa9b Compare September 7, 2023 08:19
@lukaszcz lukaszcz self-requested a review September 7, 2023 14:13
@lukaszcz lukaszcz merged commit 36b390f into main Sep 7, 2023
@lukaszcz lukaszcz deleted the 2331-dont-add-a-pipe-when-there-is-only-one-constructor branch September 7, 2023 14:20
@lukaszcz lukaszcz added this to the 0.5.0 milestone Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't add a pipe when there is only one constructor
2 participants