Skip main navigation

Why I/O?

While visiting the National Museum of Computing, Dr Jeremy Singer takes time to explain about input and output in computer systems.
JEREMY: How do computer programs interact with the outside world?
Using input and output. In this dissected PC hardware here, we see the input might arrive when the user presses keys on the keyboard or wiggles the mouse or, perhaps, when the file is read into memory from the disk. Outputs are visible to the external surroundings of the PC when the program writes data to the graphics card to be displayed on the screen or, perhaps, where a file is written back to disk. Haskell programs use something called the IO monad to interact with input/output. We’ll go into more detail about I/O and monads later on in the course. But for now, we just need to know two things.
Number one, when a function is using input or output, its type must contain IO. And number two, the IO monad ensures that input/output operations occur in a fixed sequence. For example, we must check the red button is pressed before we launch the missiles.
I’m going to invite you to look at the next interactive tutorial, now, which covers I/O in Haskell. Our I/O operations are much more mundane than launching missiles. We’ll just be writing strings to the console using putStrLn and reading character input from the standard terminal using getLine. As you do the tutorial, watch out and see where the IO type pops up. Thanks.

Computers interact with the outside world via input and output (I/O). The Haskell programming language has specific support for I/O operations, which we will explore in the next few steps.

This article is from the free online

Functional Programming in Haskell: Supercharge Your Coding

Created by
FutureLearn - Learning For Life

Our purpose is to transform access to education.

We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.

We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.

Learn more about how FutureLearn is transforming access to education