O'Reilly logo

Thinking Functionally with Haskell by Richard Bird

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 2

Expressions, types and values

In Haskell every well-formed expression has, by definition, a well-formed type. Each well-formed expression has, by definition, a value. Given an expression for evaluation,

  • GHCi checks that the expression is syntactically correct, that is, it conforms to the rules of syntax laid down by Haskell.
  • If it is, GHCi infers a type for the expression, or checks that the type supplied by the programmer is correct.
  • Provided the expression is well-typed, GHCi evaluates the expression by reducing it to its simplest possible form to produce a value. Provided the value is printable, GHCi then prints it at the terminal.

In this chapter we continue the study of Haskell by taking a closer look at these processes.

2.1 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required