Great video as always! - Just one minor note, using a case class for a newtype is a bad idea because of copy. So you can have BarCode(1-12345-12345).map(_.copy(code = "Whatever")) and now you have a faulty BarCode.
Thanks for taking us all the way to opaque types. I have been using value classes for a while without noticing issues but opaque types looks to be an improvement. Hopefully, having dependencies of Spark and Akka won't delay me from moving to Scala 3 for too long. I might separate out the Spark module if they take a long time.
Question about 20:50: this code actually does compile for me: I can assign any string to "val barcode: BarCode =". Was this changed for the release version of Scala 3?
Great video again, thank you! I have a question. I've been using refined types to accomplish this type of strong modeling. Is there a relationship between value classes or new opaque types? Again, thank you!
Glad you liked it! Value classes, newtypes and opaque types are different approaches to the same problem of "hiding" a piece of information (like a string) behind a completely new type that MEANS something in particular for you.
Great video as always! - Just one minor note, using a case class for a newtype is a bad idea because of copy. So you can have BarCode(1-12345-12345).map(_.copy(code = "Whatever")) and now you have a faulty BarCode.
Thanks!
Thanks for taking us all the way to opaque types. I have been using value classes for a while without noticing issues but opaque types looks to be an improvement. Hopefully, having dependencies of Spark and Akka won't delay me from moving to Scala 3 for too long. I might separate out the Spark module if they take a long time.
Nice, glad to hear you found value in these!
@@rockthejvm
Excuse the pun. Great video thank you.
Interesting! Thanks for the alternative to supertagged. The `@newtype` annotation seems like a much cleaner way to define the types.
Yep - glad it helped!
Question about 20:50: this code actually does compile for me: I can assign any string to "val barcode: BarCode =". Was this changed for the release version of Scala 3?
great content as always !
Thanks you for the video! :-))
Great video again, thank you!
I have a question. I've been using refined types to accomplish this type of strong modeling. Is there a relationship between value classes or new opaque types? Again, thank you!
Glad you liked it!
Value classes, newtypes and opaque types are different approaches to the same problem of "hiding" a piece of information (like a string) behind a completely new type that MEANS something in particular for you.
question about 17:56 - you're createing an either every time. why don't you count this as runtime overhead?
You have to create some sort of error case, which would have happened anyway. It's the wrapper class that eliminates the runtime overhead.
What editor/IDE are you using?
Intellij + Scala plugin:
jetbrains.com/idea
(not affiliated in any way, I just like the tool)
Thank you for your videos!
Luckily the macro plugin is not needed anymore in 2.13
Indeed.