12 Functional input/output
- Applying effects safely from inside contexts
- Combining effects for success and failure
- Safely reading data
- Using the
IO
type and imperative-like control structures - Combining
IO
operations
So far you’ve learned how to write safe programs that haven’t produced any usable results. You’ve learned how to compose true functions to build more powerful functions. More interestingly, you’ve learned how to use nonfunctional operations in a safe, functional way. Nonfunctional operations are operations producing side effects such as throwing exceptions, changing the outside world, or depending on the outside world to produce a result. For example, you learned how to take an integer division, which is a potentially unsafe operation, and turn it into a safe one by using it inside a computational context. Here are some examples of computational contexts you’ve created in previous chapters: