Conversation
|
After working on an elm-review rule with a lot of AST manipulation, I'm convinced that elm-syntax should track line breaks and comments within the AST. With that it should be possible to generate elm-review rule fixes by modifying the AST instead of needing to edit strings. This would make it much harder (maybe impossible) to make fixes that cause syntax errors, and probably will improve performance too since the AST doesn't need to be parsed again or require elm-format. |
|
The tuple one seems really strange to me. tuples, units and parenthesizing are semantically very different and it's still not exhaustive since tuples can't have more than three elements.
Some variants still seem to have inconsistent names, namely
For all the
yes. All the other changes sound awesome! |
I'm conflicted about this. Having Unit, Parenthesized, Tuple2, and Tuple3 does make the usage more clear and prevents the user from creating larger tuples that the compiler will reject. On the other hand, very often when working with the AST, I just want to do Also, while 4+ elements is not a valid tuple. Should it be considered a syntax error? Maybe it's in the same class of errors as defining two top level functions with the same name. Or referencing a function that doesn't exist. |
I feel like this extra convenience doesn't have to be baked into the type at the cost of safety and understandability. From my experience from the perspective of an |
|
These are all valid points that I want to discuss (I think I also disagree with some of the changes already in the branch), but I don't want this PR to become the place for discussion, considering how many changes it includes and will include. I will lock the discussion for this issue. @lue-bird @MartinSStewart Do you mind creating new issues to discuss these? I'll do the same |
cab4987 to
fff26eb
Compare
afc4344 to
45f893f
Compare
eff82e1 to
0f43132
Compare
0f43132 to
7ccc635
Compare
7ccc635 to
1787a7f
Compare
This PR contains a pull request containing all breaking changes for the next major release v8 and all subsequent work we do that can't or shouldn't target v7.
This is itself a rebase and cherry-pick of all the changes done on the previous
v8branch, which should probably not be touched anymore.The intent is to get as many breaking changes into this version so that we can avoid needing to release a v9 in the future, as that will impact all the tools that directly or indirectly depend on this project, including but not limited to
elm-review.Main goals
Here are a few of the main intentions of the tool:
"or""".RecordUpdateExpressionwithout any field assigments, so those become a non-empty list.RecordUpdateExpressionis inconsistent withRecordExpr.Proposals for changes to come in
v8can be created and found with thebreaking changelabel. Feel free to suggest your own!Note: We are still maintaining
v7on themasterbranch. If we have changes to apply to v7, we will likely rebase this branch often (leading to potential conflicts for branches that target this branch).Summary of changes so far
Note that there is still plenty of work to be done and nothing here is set in stone. If you have any suggestions or concerns, please let us know by opening a new issue.
You can view the
CHANGELOGhere (underUnreleased): https://github.com/stil4m/elm-syntax/blob/breaking-changes-v8/CHANGELOG.md, which should be the most up to date list of changes.Breaking changes
Expression
ApplicationFunctionCallApplication (List (Node Expression))-->Application (Node Expression) (List (Node Expression))(should this be a non empty-list?)RecordUpdateExpressionRecordUpdateRecordUpdate (Node String) (List (Node RecordSetter))->RecordUpdateExpression (Node String) (Node RecordSetter) (List (Node RecordSetter))CaseExpressionCaseCaseBlockmakes sure there is at least one element:{ expression : Node Expression, cases : Cases }->{ expression : Node Expression, firstCase : Case, restOfCases : List Case }Case (Node Expression) (NonEmptyList ( Node Pattern, Node Expression ))?TupledExpressionis renamed toTupleExpressionUnitExpris removed in favor of usingTupleExpressionParenthesizedExpressionis removed in favor of usingTupleExpressionLambdahas a non-empty list of arguments: Its fieldargs : List (Node Pattern)becomesfirstArg : Node DestructurePatternandrestOfArgs : List (Node DestructurePattern).RecordAccessFunction(.field) now doesn't include the.in the string it contains (though the.is still included in the node's range).LiteralStringLiteralStringLiteralTypewhich indicates whether the string is using"" or"""(Add information to Expression about which quotes a Literal is made of #189)Floatableis renamed toFloatLiteralIntegeris renamed toIntegerLiteralHexis renamed toHexLiteralListExpris renamed toListLiteralOperatorApplicationis renamed toOperationRecordExpris renamed toRecordIfBlockis renamed toIfGLSLExpressionis renamed toGLSLDeclaration
Destructuringvariant (which was impossible for Elm 0.19)documentationfield. This removes these comments from the AST'scommentslist.Type
firstConstructorand arestOfConstructorsfield instead ofconstructorsfield.TypeAnnotation
GenericTypeis renamed toVarTypedis renamed toTypeTupledis renamed toTupleUnitis removed in favor of usingTuplePattern
FloatPatternhas been removed, as that is a syntax error in ELm 0.19.DestructurePattern
New module representing the patterns available in a destructuring pattern (in function arguments for instance). This is used in:
Expression.FunctionImplementationExpression.LetDestructuringExpression.LambdaExposing
Explicithas a non-empty list of elements:Explicit (List (Node TopLevelExpose))->Explicit (Node TopLevelExpose) (List (Node TopLevelExpose))Port
New module representing the data for a port.
Range
Range.emptyRangefunction in favor ofRange.emptyintroduced inv7.3.0.Parsing and processing
v7.3.0introducedElm.Parser.parseToFileto combineElm.Parser.parseandElm.Processing.processto avoid having post-processing the resultingRawFile(to fix the documention comments and to re-balance the AST based on operator precedence).In
v8we don't need any post-processing anymore, so:Elm.Parser.parseToFileis renamed toElm.Parser.parse, removing the oldElm.Parser.parseElm.Processingmodule is removed.Misc