Hostname: page-component-586b7cd67f-t7czq Total loading time: 0 Render date: 2024-11-25T07:08:32.300Z Has data issue: false hasContentIssue false

Global variables in Haskell

Published online by Cambridge University Press:  06 August 2004

JOHN HUGHES
Affiliation:
Department of Computing Science, Chalmers University of Technology, S-412 96 Göteborg, Sweden (e-mail: [email protected])
Rights & Permissions [Opens in a new window]

Abstract

Core share and HTML view are not available for this content. However, as you have access to this content, a full PDF is available via the ‘Save PDF’ action button.

Haskell today provides good support not only for a functional programming style, but also for an imperative one. Elements of imperative programming are needed in applications such as web servers, or to provide efficient implementations of well-known algorithms, such as many graph algorithms. However, one element of imperative programming, the global variable, is surprisingly hard to emulate in Haskell. We discuss several existing methods, none of which is really satisfactory, and finally propose a new approach based on implicit parameters. This approach is simple, safe, and efficient, although it does reveal weaknesses in Haskell's present type system.

Type
FUNCTIONAL PEARL
Copyright
© 2004 Cambridge University Press
Submit a response

Discussions

No Discussions have been published for this article.