A switch
expression allows you to match / destructure almost any kind of value (array, list, records, strings, numbers, variants, etc). Each branch (pattern) of a switch
expression must return a value of the same type.
type shape = Circle(float) | Square(float)
let shape = Square(3.0)
let message = switch shape {
| Circle(radius) => "Circle with radius " ++ Float.toString(radius)
| Square(length) => "Square with sides of length " ++ Float.toString(length)
}