fold. The former takes a single argument function and calls it on each element of the list, while the latter takes a two-argument function which is used to combine all the elements:
Aand returning a
A -> B. It's easy to remember when you think about the arrow as representing a transformation from type
Intand returning a
Textwould be typed as
Real -> Int -> Text. The last part of such an arrow chain is the return value, while all the parts before are consecutive arguments.
add1node does not set any arguments, thus the output type is
Int -> Int -> Int,
add2node has the second argument connected, so the output type is
Int -> Int. Note the
_in it's expression. This underscore introduces explicit currying for this argument –
add _ number1means "set the second argument and leave the first one unapplied",
add3node applies the first argument and leaves the second one. There is no need for the
_in this case, since the applied argument precedes the unapplied. The type is the same as that of
add2, since both arguments have the same type.
add4node is fully applied, so the return type is just