### Activity Sequence: Haskell

This is as an illustrative example for how Expression Tutor activities could be used in a Haskell course. The content on this page may not be understandable for someone without significant prior knowledge.

In Haskell, binary operators really are curried functions. That is, a binary operator is not a function with two arguments, but it is a function of one argument that returns a function of one argument that returns a result.

#### Binary Operators are Curried Functions

Let's look at `+`

. Take the following Haskell expression:

`1 + 2`

Below is a tree representation of the above expression. You can see that functions are values in Haskell: the + is its own node in the tree. It has type Num a => a -> a -> a. This means that given a type `a`

that is a `Num`

, the `+`

function has the type `a -> a -> a`

. Functions are curried, that is, the `+`

function takes an `a`

(the first operand) and returns a function. That function takes an `a`

(the second operand) and returns an `a`

.

#### Now you provide the types

Here is a bigger expression that includes functions such as `show`

,`++`

, `mod`

, and `==`

. It also includes the conditional `if then else`

.

`show n ++ " is " ++ if mod n 2 == 0 then "even" else "odd"`

Below is a tree representation of the above expression. Your task is to annotate each node of the tree with the appropriate type. To do so, select each node and pick one of the suggested types or enter a type for that node.