I am trying to understand associative in monoid.
From the book, it says:
Associativity simply says that you can associate the arguments of your operation differently and the result will be the same.
For example:
Prelude> (1 + 9001) + 9001
18003
Prelude> 1 + (9001 + 9001)
18003
And about commutative:
This is not as strong a property as an operation that commutes or is commutative. Commutative means you can reorder the arguments and still get the same result. Addition and multiplication are commutative, but (++) for the list type is only associative.
The example above is associative and commutative but what is the difference? I can not see the difference.
Take string concatenation as an example. Suppose you're using a language which uses +
for string concatenation. That's naturally associative, as the grouping doesn't matter:
("a" + "b") + "c" == "abc"
"a" + ("b" + "c") == "abc"
But the operand order definitely matters:
"a" + "b" = "ab"
"b" + "a" = "ba"
See more on this question at Stackoverflow