Book contents
- Frontmatter
- Contents
- Preface
- Chapter 1 Introduction
- Chapter 2 First steps
- Chapter 3 Types and classes
- Chapter 4 Defining functions
- Chapter 5 List comprehensions
- Chapter 6 Recursive functions
- Chapter 7 Higher-order functions
- Chapter 8 Functional parsers
- Chapter 9 Interactive programs
- Chapter 10 Declaring types and classes
- Chapter 11 The countdown problem
- Chapter 12 Lazy evaluation
- Chapter 13 Reasoning about programs
- Appendix A Standard prelude
- Appendix B Symbol table
- Bibliography
- Index
Chapter 2 - First steps
- Frontmatter
- Contents
- Preface
- Chapter 1 Introduction
- Chapter 2 First steps
- Chapter 3 Types and classes
- Chapter 4 Defining functions
- Chapter 5 List comprehensions
- Chapter 6 Recursive functions
- Chapter 7 Higher-order functions
- Chapter 8 Functional parsers
- Chapter 9 Interactive programs
- Chapter 10 Declaring types and classes
- Chapter 11 The countdown problem
- Chapter 12 Lazy evaluation
- Chapter 13 Reasoning about programs
- Appendix A Standard prelude
- Appendix B Symbol table
- Bibliography
- Index
Summary
In this chapter we take our first proper steps with Haskell. We start by introducing the Hugs system and the standard prelude, then explain the notation for function application, develop our first Haskell script, and conclude by discussing a number of syntactic conventions concerning scripts.
The Hugs system
As we saw in the previous chapter, small Haskell programs can be executed by hand. In practice, however, we usually require a system that can execute programs automatically. In this book we use an interactive system called Hugs, which is the most widely used implementation of Haskell.
The interactive nature of Hugs makes it well suited for teaching and prototyping, and its performance is sufficient for most applications. However, if greater performance or a stand-alone executable version of a program is required, a number of compilers for Haskell are also available, of which the most widely used is the Glasgow Haskell Compiler. This compiler also has an interactive version that operates in a similar manner to Hugs, and can readily be used in its place for the purposes of this book.
The standard prelude
When the Hugs system is started it first loads a library file called Prelude.hs, and then displays a > prompt to indicate that the system is waiting for the user to enter an expression to be evaluated.
- Type
- Chapter
- Information
- Programming in Haskell , pp. 10 - 16Publisher: Cambridge University PressPrint publication year: 2007