Sorry, this isn't an issue as such, I was just looking for more information on how newtype works. The README says something like this is generated:
package object types {
type WidgetId = WidgetId.Type
object WidgetId {
type Repr = Int
type Base = { type WidgetId$newtype }
trait Tag
type Type <: Base with Tag
def apply(x: Int): WidgetId = x.asInstanceOf[WidgetId]
implicit final class Ops$newtype(val $this$: Type) extends AnyVal {
def toInt: Int = $this$.asInstanceOf[Int]
}
}
}
I get the basic idea that you use macros to generate a value class but I wasn't sure why so many intermediate types are defined or what type Base = { type WidgetId$newtype }, which looks abstract, did?
Any more info would be much appreciated, thanks!!!
Sorry, this isn't an issue as such, I was just looking for more information on how newtype works. The README says something like this is generated:
I get the basic idea that you use macros to generate a value class but I wasn't sure why so many intermediate types are defined or what
type Base = { type WidgetId$newtype }
, which looks abstract, did?Any more info would be much appreciated, thanks!!!