Type alias vs case class to add semantic meaning to data structures

There are some additional middle ground alternatives to the three cases, i.e. Value Classes and Tagged Types. As @martijnhoekstra notes, it’s a tradeoff to be assessed for each specific case. There has been a similar discussion in this forum recently.

Your specific example might raise the additional question whether you have an algebraic data type Token here, which would push the choice towards a sealed trait with case class/value class variants.

3 Likes