estatico / scala-newtype

NewTypes for Scala with no runtime overhead
Apache License 2.0
540 stars 31 forks source link

Support unboxed newtypes for primitives #13

Closed joroKr21 closed 6 years ago

joroKr21 commented 6 years ago

This is only possible with NewSubType but I think it's still useful.

kailuowang commented 6 years ago

Here is another motivation for adding NewSubType support to macro:I found that NewSubType works better with shapeless. (i.e. when deriving things using shapeless, case classes with field of NewType type has some kinkiness, while NewSubType seems just working fine. )

carymrobbins commented 6 years ago

A couple of ideas for how this would look -

@newtype(subtype = true) class Foo(x: Int)

@newtype.sub class Foo(x: Int)

@newsubtype class Foo(x: Int)

I'm not particularly happy with any of them, so if anyone has a better idea for the syntax, feel free to suggest it.

kailuowang commented 6 years ago

My preference isn't very strong but here it is . 3 > 1 > 2

carymrobbins commented 6 years ago

This has been merged to master as @newsubtype, which will be available in the 0.4.0 release.