February 2019
Beginner to intermediate
180 pages
4h 4m
English
Let's say that we'd like to add a field to seat to hold the date a seat was purchased:
type seat = { section, price: int, person: option(person), dateSold: option(string)};
Now, we've introduced the possibility of an invalid state in our code. Here's an example of such a state:
let seat = { section: Pit, price: 42, person: None, dateSold: Some("2018-07-16")};
In theory, the dateSold field should only hold a date when the person field holds a ticket holder. The ticket has a sold date, but no owner. We could look through our imaginary implementation to verify that this state would never happen, but there would still be the possibility that we missed something, or that some minor refactor introduced a bug that ...
Read now
Unlock full access