-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Adding Id.apply #4036
Adding Id.apply #4036
Conversation
You could just do |
@joroKr21 sure, but a lot of times I have wanted to use |
@BalmungSan another way with help of the existing Cats syntax could be import cats._
import cats.syntax.all._
val a = 123
println(a.pure[Id].map(_ + 456)) https://scastie.scala-lang.org/satorg/Qq3pz0kaT8CLJqfTye2VBA/17 |
Since Scala 2.13 there is also a standard library |
@satorg oh nice, I kind of always forget about it. I guess the point of the PR is not really if this is the best way or not to access it. But, rather why not having the |
Yeah it's definitely a valid point to discuss on it's own merits whether Regarding the type class instances, that wouldn't work in Scala 2 anyway because type aliases can't have a companion object. I.e. you can have an |
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.
I like this change. It's trivial and it provides an ergonomic improvement that I would use from time to time.
I personally don't mind this change. Just to note: there's property("Id#apply") {
forAll { (a: Int) =>
assert(Id(a) == (a: Id[Int])) // or `== a.pure[Id]` or even just `== a`
}
} |
Uhm that error is not related to my change, is it? |
I restarted the build. |
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.
There are other ways, but I've looked for this way before. It's intuitive to me.
I wish it lived in cats.data
, but it's not easy to get there from here in Cats 2.
I hope there isn't a reason for not doing this.