Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

Latest commit

 

History

History
31 lines (20 loc) · 1.05 KB

sum_type.md

File metadata and controls

31 lines (20 loc) · 1.05 KB

Sum type

The Concept

A sum type is a data structure which value can have several different, but fixed, types.

What to cover

  • 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?

Exercises

Valentine date

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.

Implementations

Track Exercise Changes
F# strings None