Hacker News new | ask | show | jobs
by jacobgreenleaf 4582 days ago
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.
1 comments

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.
Type aliases do not solve this. The closest you can get is using the new value classes & those have some very big caveats