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.