I do not understand why the signature of foldl
is like that.
Standard ML of New Jersey v110.79 [built: Tue Aug 8 23:21:20 2017]
- foldl;
val it = fn : ('a * 'b -> 'b) -> 'b -> 'a list -> 'b
In particular, the arrows ->
should've been asterisk *
like the following:
val it = fn : ('a * 'b -> 'b) * 'b * 'a list -> 'b
And the reason is because foldl
takes the following:
('a * 'b -> 'b)
that compares & returns one of two strings; assuming acc
is 'b, thus, returning acc
acc
& 'a list
to compare them.acc
.*
entails it to be a tuple, and which necessitates that all the components of the tuple will have to be provided... ->
entails currying
, which allows partial application
. Both are 2 different semantics.
Also, it is interesting that you write
...foldl takes a function that compares two strings...
.
foldl
is generic and quite polymorphic, so why will it work only with string
. A particular function application
may work over string
data, but not the function definition
itself.