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

Formatting specs with 'when' keyword #90

Closed
erszcz opened this issue Mar 17, 2020 · 0 comments · Fixed by #125
Closed

Formatting specs with 'when' keyword #90

erszcz opened this issue Mar 17, 2020 · 0 comments · Fixed by #125
Assignees
Labels
Milestone

Comments

@erszcz
Copy link

erszcz commented Mar 17, 2020

Based on esl/exml#52 it turns out that the formatter doesn't currently handle when clauses in specs well (probably in types, too, though they don't seem to be useful there). The specific points were:

esl/exml#52 (comment)
https://github.com/esl/exml/pull/52/files#r393059362
https://github.com/esl/exml/pull/52/files#r393072500

Given an input spec and function head:

-spec subelement_with_name_and_ns(exml:element(), binary(), binary(), Other) ->
    exml:element() | Other.
subelement_with_name_and_ns(Element, Name, NS, Default) -> ...

The formatter currently prints:

-spec subelement_with_name_and_ns(exml:element(),
                                  binary(),
                                  binary(),
                                  Other) -> exml:element() | Other.

We're proposing the formatter to automatically expand long specs (of more than 3 arguments) to the following form instead:

-spec subelement_with_name_and_ns(Element, Name, NS, Default) -> R when
      Element :: exml:element(),
      Name :: binary(),
      NS :: binary(),
      Default :: Other,
      R :: exml:element() | Other.

Alternatively, it would be beneficial if it could introduce line breaks before the return value, not between the function arguments:

-spec subelement_with_name_and_ns(exml:element(), binary(), binary(), Other) ->
      exml:element() | Other.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants