Skip to content

Instantly share code, notes, and snippets.

@supermanue
Last active April 11, 2022 17:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save supermanue/a1651b038f88d4b250ca0178dd66bab9 to your computer and use it in GitHub Desktop.
Save supermanue/a1651b038f88d4b250ca0178dd66bab9 to your computer and use it in GitHub Desktop.
Tagged Types
type Tagged[U] = { type Tag = U }
type @@[T, U] = T with Tagged[U]
trait NameTag
trait SurnameTag
type Name = String @@ NameTag
type Surname = String @@ SurnameTag
(...)
val person = Person("manuel".asInstanceOf[Name], "Rodriguez".asInstanceOf[Surname])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment