Skip to content
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.

Implement intelligent breaking for poly-var type expressions #246

Merged
merged 2 commits into from
Jan 22, 2021

Conversation

IwanKaramazow
Copy link
Contributor

Fixes #245

Given:

type currencyPoly = [#USD
  | #CAD | #EUR]

type currencyPoly = [#USD | #CAD | #EUR]

we have two different layouts:

In the first example the user wrote them over multiple lines.
The second has them on one line.
This commit implements a new strategy to print these two examples.
We now look at the style of the author: did he write it over multiple lines or not?

If it is on one line, keep it on one line (unless it breaks the column width).
If it is written over multiple lines, force break it over multiple lines.
This is also consistent with how we print variant declaration.

Iwan added 2 commits January 22, 2021 18:11
Fixes #245

Given:
```rescript
type currencyPoly = [#USD
  | #CAD | #EUR]

type currencyPoly = [#USD | #CAD | #EUR]
```
we have two different layouts:

In the first example the user wrote them over multiple lines.
The second has them on one line.
This commit implements a new strategy to print these two examples.
We now look at the style of the author: did he write it over multiple lines or not?

If it is on one line, keep it on one line (unless it breaks the column width).
If it is written over multiple lines, force break it over multiple lines.
This is also consistent with how we print variant declaration.
@IwanKaramazow IwanKaramazow merged commit b4a476d into master Jan 22, 2021
@IwanKaramazow IwanKaramazow deleted the intelligent-poly-variants branch January 22, 2021 17:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Intelligent formatting only works for ADTs but not polymorphic variants
1 participant