-
Notifications
You must be signed in to change notification settings - Fork 30
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
Ongoing branch for v8 #188
base: master
Are you sure you want to change the base?
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
v8
branch, 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"""
.RecordUpdateExpression
without any field assigments, so those become a non-empty list.RecordUpdateExpression
is inconsistent withRecordExpr
.Proposals for changes to come in
v8
can be created and found with thebreaking change
label. Feel free to suggest your own!Note: We are still maintaining
v7
on themaster
branch. 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
CHANGELOG
here (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
Application
FunctionCall
Application (List (Node Expression))
-->Application (Node Expression) (List (Node Expression))
(should this be a non empty-list?)RecordUpdateExpression
RecordUpdate
RecordUpdate (Node String) (List (Node RecordSetter))
->RecordUpdateExpression (Node String) (Node RecordSetter) (List (Node RecordSetter))
CaseExpression
Case
CaseBlock
makes 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 ))
?TupledExpression
is renamed toTupleExpression
UnitExpr
is removed in favor of usingTupleExpression
ParenthesizedExpression
is removed in favor of usingTupleExpression
Lambda
has a non-empty list of arguments: Its fieldargs : List (Node Pattern)
becomesfirstArg : Node DestructurePattern
andrestOfArgs : 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).Literal
StringLiteral
StringLiteralType
which indicates whether the string is using"
" or"""
(Add information to Expression about which quotes a Literal is made of #189)Floatable
is renamed toFloatLiteral
Integer
is renamed toIntegerLiteral
Hex
is renamed toHexLiteral
ListExpr
is renamed toListLiteral
OperatorApplication
is renamed toOperation
RecordExpr
is renamed toRecord
IfBlock
is renamed toIf
GLSLExpression
is renamed toGLSL
Declaration
Destructuring
variant (which was impossible for Elm 0.19)documentation
field. This removes these comments from the AST'scomments
list.Type
firstConstructor
and arestOfConstructors
field instead ofconstructors
field.TypeAnnotation
GenericType
is renamed toVar
Typed
is renamed toType
Tupled
is renamed toTuple
Unit
is removed in favor of usingTuple
Pattern
FloatPattern
has 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.FunctionImplementation
Expression.LetDestructuring
Expression.Lambda
Exposing
Explicit
has 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.emptyRange
function in favor ofRange.empty
introduced inv7.3.0
.Parsing and processing
v7.3.0
introducedElm.Parser.parseToFile
to combineElm.Parser.parse
andElm.Processing.process
to avoid having post-processing the resultingRawFile
(to fix the documention comments and to re-balance the AST based on operator precedence).In
v8
we don't need any post-processing anymore, so:Elm.Parser.parseToFile
is renamed toElm.Parser.parse
, removing the oldElm.Parser.parse
Elm.Processing
module is removed.Misc