Skip to content
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

How can I create a custom method with path? #159

Closed
user753 opened this issue May 3, 2023 · 0 comments · Fixed by #181
Closed

How can I create a custom method with path? #159

user753 opened this issue May 3, 2023 · 0 comments · Fixed by #181
Assignees
Labels

Comments

@user753
Copy link

user753 commented May 3, 2023

I have something like this

case class State(foo: Int)

class Store {
  var state = State(100)
  
  inline def set[A](inline path: State => A, value: A): Unit = {
    state = modify(state)(path).setTo(value)
  }

  
}

I what to implement set method so I could use it like this set(_.foo, 200)
But there is an error

    set(_.foo, 200)
    ^^^^^^^^^
Unsupported path element. Path must have shape: _.field1.field2.each.field3.(...), got: ((_$16: State) => _$16.foo)

Is there any way to do it?

@user753 user753 changed the title How can I create custom method with path? How can I create a custom method with path? May 3, 2023
@KacperFKorban KacperFKorban self-assigned this Jul 17, 2023
KacperFKorban added a commit that referenced this issue Jul 17, 2023
modification path in Scala 3 macro

closes #159
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants