What would be the Racket/TypedRacket equivalent of Haskell's sum types?
For example:
data MusicGenre = HeavyMetal | Pop | HardRock
What would be the Racket/TypedRacket equivalent of Haskell's sum types?
For example:
data MusicGenre = HeavyMetal | Pop | HardRock
On
You may also be interested in define-datatype provided by typed-racket-datatype. You can combine that with match from racket/match to branch on the cases.
You can use
define-typeand a union of symbols for this kind of sum type: