Hacker News new | ask | show | jobs
by jayshua 1614 days ago
The type system can force you to handle both cases - the data being in the expected & typed form, and the data not being in the expected form.

You would have a function like this:

parseJsonString : String -> Result Error Person

Where Result is a value that is either an Error or a Person.

To get the Person value out, the type system forces you to also do something with the Error if it exists. Not handling both possibilities in some way is a type error.