A module to define generic functions for monoid.
For instance, we defined generic concat in this module using Monoid type as follows.
concat : Monoid a -> List a -> a
concat m =
List.foldr (append m) (empty m)
concat string ["foo", "bar", "baz"]
--> "foobarbaz"
concat list [[1, 2, 3], [4, 5], [6]]
--> [1, 2, 3, 4, 5, 6]
concat sum [Sum 1, Sum 2, Sum 3, Sum 4] -- 1 + 2 + 3 + 4
--> Sum 10
concat sum <| List.map Sum [1, 2, 3, 4] -- 1 + 2 + 3 + 4
--> Sum 10
concat product <| List.map Product [1, 2, 3, 4] -- 1 * 2 * 3 * 4
--> Product 24Monoid under addition
Monoid under multiplication.
Main type.