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

type aliases #32

Closed
nrc opened this issue Oct 17, 2016 · 4 comments · Fixed by #96
Closed

type aliases #32

nrc opened this issue Oct 17, 2016 · 4 comments · Fixed by #96

Comments

@nrc
Copy link
Member

nrc commented Oct 17, 2016

Again, I'd like to discuss generics separately (#29), so that should make this one pretty trivial.

@strega-nil
Copy link

strega-nil commented Oct 17, 2016

// generally
type X /* <- one line */ = Foo;
// need to break
type LongName = /* <- don't break here */
  FooBar; /* <- pull this down */

@nrc
Copy link
Member Author

nrc commented Nov 29, 2016

Pretty simple one, I think, ready for FCP.

@nrc
Copy link
Member Author

nrc commented Mar 10, 2017

Questions:

If there is a where clause, should we leave on one line, e.g.,

type Foo<T> where T: Foo = Bar;

I propose not, since that is what we agreed for where clauses in general.

In which case how should we break this?

type Foo<T>
where
    T: Foo,
= Bar;

Would be my suggestion, the only downside is that we had previously decided to break after the = for the non-where case if we need to break the line. Perhaps we should revisit that?

And to check - trailing comma here is OK?

@joshtriplett
Copy link
Member

@nrc Type aliases with where clauses seem like a sufficiently different case to be worth evaluating separately from functions with where clauses. And they have kind of an awful order of terms, which we can't do anything about.

I think I'd argue that in the majority of cases type aliases should inline the constraints inside the <>, to improve readability. In the case of a where clause, though, I'd agree with your proposed formatting. The standard response to someone going "ewww" in reaction can be to suggest not using a where clause in a type alias. :)

I don't think we should change the decision to break after the = in the non-where case.

@nrc nrc added ready-for-PR and removed P-high labels May 1, 2017
nrc added a commit that referenced this issue Sep 14, 2017
@nrc nrc mentioned this issue Sep 14, 2017
nrc added a commit that referenced this issue Nov 13, 2017
@nrc nrc closed this as completed in #96 Nov 13, 2017
@nrc nrc mentioned this issue Feb 5, 2018
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants