You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems like no one on the internet knows how to do this properly, so after drunkenly stumbling upon the correct syntax I decided to throw this small section together.
But what about the cases where we want more flexibility (eg. we know the subset of methods that will be called but not neccessarily their order)?
270
+
271
+
#### Iterative deconstruction of a function expression
272
+
273
+
Let's imagine we need a macro that collects names of methods used in an expression of type `FieldName => FieldName`, for a definition of `FieldName` that looks like this:
// this matches an identity function, i.e. the end of our loop
296
+
case'{ (arg: FieldName) => arg } => acc
297
+
endrecurse
298
+
299
+
recurse(func, Nil)
300
+
```
301
+
302
+
For more details on how patterns like `$body(arg)` work please refer to docs section on [the HOAS pattern](https://dotty.epfl.ch/docs/reference/metaprogramming/macros.html#hoas-patterns-1).
303
+
304
+
If we were to use this on an expression like this one:
0 commit comments