[–] greydius 10y ago ↗ Haskell has newtype for this purpose, with the benefit that the compiler removes the added overhead of the additional data type. [–] wickedshimmy 10y ago ↗ Value classes serve this purpose in Scala: `case class Id(id: Long) extends AnyVal` will have long-typed values at runtime (*mostly). [–] Psyonic 10y ago ↗ Is *mostly even true?Given the list of restrictions here: http://docs.scala-lang.org/overviews/core/value-classes.htmlIt seems to me that you'd have to be fairly careful to have any confidence your not instantiating classes for them.Do you know if there are any compiler flags or other way to know if your value classes are working as expected?
[–] wickedshimmy 10y ago ↗ Value classes serve this purpose in Scala: `case class Id(id: Long) extends AnyVal` will have long-typed values at runtime (*mostly). [–] Psyonic 10y ago ↗ Is *mostly even true?Given the list of restrictions here: http://docs.scala-lang.org/overviews/core/value-classes.htmlIt seems to me that you'd have to be fairly careful to have any confidence your not instantiating classes for them.Do you know if there are any compiler flags or other way to know if your value classes are working as expected?
[–] Psyonic 10y ago ↗ Is *mostly even true?Given the list of restrictions here: http://docs.scala-lang.org/overviews/core/value-classes.htmlIt seems to me that you'd have to be fairly careful to have any confidence your not instantiating classes for them.Do you know if there are any compiler flags or other way to know if your value classes are working as expected?
[–] sonicrocketman 10y ago ↗ > [Re: Type Safety] It may not feel like much, but it is huge. Here I can only ask you to believe me.That was the part I agreed with you the most.
4 comments
[ 3.4 ms ] story [ 22.3 ms ] threadGiven the list of restrictions here: http://docs.scala-lang.org/overviews/core/value-classes.html
It seems to me that you'd have to be fairly careful to have any confidence your not instantiating classes for them.
Do you know if there are any compiler flags or other way to know if your value classes are working as expected?
That was the part I agreed with you the most.