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

More Documentation #16

Open
TimWSpence opened this issue Mar 28, 2018 · 0 comments
Open

More Documentation #16

TimWSpence opened this issue Mar 28, 2018 · 0 comments

Comments

@TimWSpence
Copy link

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!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant