Re:Scala – 1 Star – Would Not Program Again
by jacobgreenleaf on Monday December 02, 2013 @12:49AM
(#6831944)
In Haskell, and I assume Scala, you can name types of the same form, so I might say a TimeSeries is a list of floating point values. If I use that data type, you can't accidentally pass a different kind of list of floating points even though they're the same type.
[ Parent
| on HN ]
Re:Scala – 1 Star – Would Not Program Again
by p4lindromica on Monday December 02, 2013 @03:39AM
(#6832526)
Yes, you can do this in scala with type aliases
Type aliases don't solve that problem. You need to use something like Shapeless' newtype.
Re:Scala – 1 Star – Would Not Program Again
by kasey_junk on Monday December 02, 2013 @09:06AM
(#6833670)
Type aliases do not solve this. The closest you can get is using the new value classes & those have some very big caveats