1.2 types

We define the type of a function to be on the type of input to the type of output it does, notation wise this is f::XY, for function f and types X,Y . For example:

sin :: Float -> Float
home :: Person -> Address
add :: (Int, Int) -> Int
logBase :: Float -> (Float -> Float)

On an aside, the float type is for single precision floating point numbers. The int type is for limited precision integers. We have (X,Y) defining the pair type where X,Y are pairs (it's a tuple). For notations within the code, types are Capitalized, while variables are lowercase. Similarly, parenthesis are optional in lieu of a space, i.e. sin theta == sin(theta) programmatically.

For functions with multiple inputs, such as add, you do need parenthesis to do add(x, y). You also need parenthesis for certain operations, such as sin (pi/2), as otherwise it will divide by 2 after computing sin pi. However, there's a trick that logBase does to get around something like this.

Note that logBase is defined as mapping from the type Float to the function class Float to Float. This is because the first input maps the base, and the second input is to the new function that is returned. So, these all read the same:

logBase :: Float -> Float -> Float

which is the same as the original type definition.