Haskell School of Music 1.4-1.6

Posted on March 21, 2020

These are some points of reference and notes from the book the haskell school of music chapter one.

1.4 Expressions and Values 1.5 Types 1.6 Function Types and Type Signatures

1.4 Expressions and Values

Examples of expressions are atomic values such as 42 or 'a'. There are also structured expressions such as a list of pitches, or pair of character and integer. Strings are also expressions and all of these are also values since there is no further computaion that can be done.

Expressions whose definitions result in a never ending sequence of calculations are said to diverge.

The symbol ⊥ represents the value of such expressions since the there is nothing to distinguish one divergent expression from another.

1.5 Types

Every expression and value has a type and the association of an expression with its type is called a type signature. Haskell ensures programs are well typed.

1.6 Function Types and Type Signatures

Returning to the earlier example of the simple function we can write its type signature as:

simple :: Integer -> Integer -> Integer -> Integer
simple x y z = x * (y + z)

Its a good idea to write the type before creating the function you want to define. Use of a function is called function application. Function application always has higher precedence than operator application. For example:

f x + g y
 (f x) + (g y)

Despite the difference operators are still just functions.