Skip to main content Accessibility help
×
Hostname: page-component-8448b6f56d-m8qmq Total loading time: 0 Render date: 2024-04-19T00:03:38.038Z Has data issue: false hasContentIssue false
This chapter is part of a book that is no longer available to purchase from Cambridge Core

Chapter 9 - Interactive programs

Graham Hutton
Affiliation:
University of Nottingham
Get access

Summary

In this chapter we show how Haskell can be used to write interactive programs. We start by explaining what interactive programs are, show how such programs can naturally be viewed as functions, define a number of basic interactive programs and higher-order functions for combining interactive programs, and conclude by developing a calculator and the game of life.

Interaction

A batch program is one that does not interact with the user while it is running. In the early days of computing, most programs were batch programs, run in isolation from their users in order to maximise the amount of time that the computer was performing useful work. For example, a route-planning program may take start and finish points as its input, silently perform a large number of calculations, and then produce a recommended route as its output.

Up to this point in the book we have considered how Haskell can be used to write batch programs. In Haskell such programs, and more generally all programs, are modelled as pure functions that take all their input as explicit arguments, and produce all their output as explicit results. For example, a route planner may be modelled as a function of type (Point, Point) → Route that takes a pair of points and produces a route between them.

In contrast, an interactive program is one that may take additional input from the user, and produce additional output for the user, while the program is running.

Type
Chapter
Information
Publisher: Cambridge University Press
Print publication year: 2007

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Save book to Kindle

To save this book to your Kindle, first ensure coreplatform@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

  • Interactive programs
  • Graham Hutton, University of Nottingham
  • Book: Programming in Haskell
  • Online publication: 05 June 2012
  • Chapter DOI: https://doi.org/10.1017/CBO9780511813672.010
Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

  • Interactive programs
  • Graham Hutton, University of Nottingham
  • Book: Programming in Haskell
  • Online publication: 05 June 2012
  • Chapter DOI: https://doi.org/10.1017/CBO9780511813672.010
Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

  • Interactive programs
  • Graham Hutton, University of Nottingham
  • Book: Programming in Haskell
  • Online publication: 05 June 2012
  • Chapter DOI: https://doi.org/10.1017/CBO9780511813672.010
Available formats
×