-
Notifications
You must be signed in to change notification settings - Fork 0
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
Handle destruct in function arg #10
Handle destruct in function arg #10
Conversation
It would be very nice for the review if you could split the changes to have one commit with the refactoring and one with the actual fix, if that makes sense for these changes :-) (we might also merge the refactoring part to other Merlin's branches) |
Fragment the various stages of the `node` function to facilitate understanding of its flow and the reuse of parts.
8fc4729
to
9f38a32
Compare
Is it better this way? |
It's much better, thanks ! |
I've added two tests that can handle deconstruction cases on single-field records and single-constructor sums (which seem to be the most trivial use cases for destructing in the presence of function parameters). |
"Foo" | ||
], | ||
"notifications": [] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would also be good to have tests with:
- A type with one constructor where the constructor has fields.
- A type with one constructor where the constructor has an inline record
- A gadt with multiple constructors, but where the types allow only one constructor to be well-typed. (This is harder -- a reach goal.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @goldfirere
- Works fine
- As the previous version, it generate
Ctor _
,but currently, the way that pattern are printed seems wrong. For(it wastype t = Foo of {..}
it producesFoo_
. I am currently investigating on thatsed
in test mistake from my side. Fixed now) - With GADT it seems working too
8f25c63
to
86e76b3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @xvw, thank you !
The fix is surprisingly self contained once the refactoring is moved away :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely a nice improvement over the current situation, thanks a lot !
Supports
destruct
in the presence of a function parameter.There are still some unanswered questions. For example, for the moment, the case
fun (b: bool) ->
will generatefun (true | false : bool)
. However,fun (_ as b: bool) ->
will generatefun ((false as b) | (true as b)) ->
. Introducing aliases in the first case seems to me 1, non-trivial and tends towards behavior that's hard to specify when patterns are nested.