scala-newtype
scala-newtype copied to clipboard
Advantages over AnyVal?
The README.md compares this library to Haskell's newtype
and to Tagged types. However, more crucially, it doesn't mention how this is any different/better than simply using case class Thing(value: String) extends AnyVal
.
From my understand this is an alternative to extends AnyVal
, hence this info is crucial.
See https://docs.scala-lang.org/overviews/core/value-classes.html
@CremboC you might also find this
https://failex.blogspot.com/2017/04/the-high-cost-of-anyval-subclasses.html
and this
https://github.com/barambani/http4s-extend#new-type
interesting on the subject.