In the first example, the argument is simply bound to the identifier "x"; hence, x has type LengthList a. In the second example, however, we pattern-match on the argument, and bind the contents of the LengthList to the indentifier "x". So in the second example x has type [a].
x and y are of type
[a]
, notLengthList a
.Consider these two ways of writing a function:
and
In the first example, the argument is simply bound to the identifier "x"; hence, x has type
LengthList a
. In the second example, however, we pattern-match on the argument, and bind the contents of the LengthList to the indentifier "x". So in the second example x has type[a]
.Hope that helps.
Absolutely.
This comment is hidden because it contains spoiler information about the solution