Yep: <https://github.com/arrow-kt/arrow-meta/compa...
# pattern-matching
m
Yep: https://github.com/arrow-kt/arrow-meta/compare/pattern-matching. However, I feel the need to point out that this mainly demonstrates that the desugaring is possible. I've got a hard-coded replacement right now for the matching (https://github.com/arrow-kt/arrow-meta/compare/pattern-matching#diff-b73d012976775bb9f20fed7202e2c4a2R11) - this needs to be made to dynamically scan for the properties of the class (possibly with destructuring, but have to see how feasible it is). I should have that fleshed out this weekend hopefully. I've got some ideas around how to make it work. I'm also not entirely sure the route I'm going is ideal, but it does function. There may be other use cases that make it impossible. I also don't yet have the values from the match accessible yet (for example:
Person(_, lastName) -> println(lastName)
but I have some thoughts on how to make that happen as well. My initial step here is to see what's possible and then optimize and improve things later. The good news is the match works independently from
when
(even though this example uses
when
). It matches based on a
KtCallExpression
to do the desugaring. This should mean we can match in other contexts as well (general function calls) with a little extra work. Meta doesn't yet have scopes defined for
KtCallExpression
so I wrote out a scope for that as well to support this. I had a separate PR for it originally, but merge that into the pattern-matching branch for now. I also have to see what the other properties for
KtCallExpression
are used for in other scenarios. I might also include a scope for
KtReferenceExpression
if needed. Additionally, I think I have an idea in mind for patterns with lists (head, tail patterns, etc...). I don't have this yet demonstrated (it's mainly a thought process in my head at the moment) but I might have an initial PoC around lists this weekend as well... Overall, it's very early and there's a lot of work remaining, but it's a start. I am feeling more confident that pattern matching is definitely possible, and using Meta will make things so much easier! Thank you for having this within Meta. I think it's possible to have a fairly solid prototype for most common scenarios ready within a couple months.