scala-newtype icon indicating copy to clipboard operation
scala-newtype copied to clipboard

Advantages over AnyVal?

Open CremboC opened this issue 6 years ago • 2 comments

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.

CremboC avatar Jan 30 '19 10:01 CremboC

See https://docs.scala-lang.org/overviews/core/value-classes.html

markschaake avatar Mar 29 '19 15:03 markschaake

@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.

barambani avatar May 05 '19 17:05 barambani