Monoid and semigroups

Added a fold operation to Optional
A more generic implementation of reduce.