A sum type is a data structure which value can have several different, but fixed, types.
- What sum types are in your language What can they be used for? Do they have limitations? How are they different from enums?
- How to define sum types How can they be defined?
- How to work with sum types Can pattern matching be used? Are there built-in methods that work on sum types?
This exercise chooses suitable options for a valentine's day date. The reference implementation (F#) teaches:
- What sum types are and when to use them.
- How sum types are different from enums.
- How to define a sum type, with and without data.
- How to do pattern matching on sum types.
| Track | Exercise | Changes |
|---|---|---|
| F# | strings | None |