Result

    This is where the Result type becomes helpful. It is defined like this:

    Perhaps we have a website where people input their age. We could check that the age is reasonable with a function like this:

    Error Recovery

    The Result type can also help you recover from errors. One place you see this is when making HTTP requests. Say we want to show the full text of Anna Karenina by Leo Tolstoy. Our HTTP request results in a Result Error String to capture the fact that the request may succeed with the full text, or it may fail in a bunch of different ways:

    The next chapter shows how to actually make HTTP requests, so we will run into the Result and types again very soon!