If the # operator is "correct associative", this means:
a
... for any number of arguments. It behaves like a foldr
It means that:
a -> b -> c -> d = a -> (b -> (c -> d))
Note: a -> (b -> (c -> d)) =/= ((a -> b) -> c) -> d ! It is very important.
This tells us that, say, foldr :
Ξ»> :t foldr foldr :: (a -> b -> b) -> b -> [a] -> b
It takes a function of type (a -> b -> b) and then returns ... a function that takes b and then returns ... a function that takes [a] and then returns ... a b . This means that we can use functions such as
fabc
because
fabc = ((fa) b) c
and f return two functions each time an argument is provided.
In fact, this is not very useful as such, but important information for when we want to interpret and call function types.
However, functions like (++) have associativity. If (++) remained associative, this would be very slow, so it would be correct associative.
source share