Working with the Local System

With all programs, at some point or another you’ll find yourself needing to interact with the local system. You’ve already done some of it in previous chapters when we wrote a program that asked a user to type something in, or when we printed some text to the screen, and in the last chapter, you learned a lot about how IO really works in Haskell. But reading and writing data from a terminal is just one small example of the many ways that you’ll find yourself wanting to have your program interact with the real world.

In this chapter, we’ll focus on the most common ways that you might want to have your program interact with the outside world. As we’re working through the chapter, we’ll explore practical matters like how to read files from disk and how to get command line arguments, and we’ll also explore the way that Haskell handles these types of operations (you’ve already seen some hints of this with the IO () type signature in main ).