:: Monoid m => Bool -> m -> m package:base-compat-batteries

This is a valid definition of stimes for a Monoid. Unlike the default definition of stimes, it is defined for 0 and so it should be preferred where possible.
This is a valid definition of stimes for an idempotent Monoid. When mappend x x = x, this definition should be preferred, because it works in <math> rather than <math>
Repeat a value n times.
mtimesDefault n a = a <> a <> ... <> a  -- using <> (n-1) times
In many cases, `stimes 0 a` for a Monoid will produce mempty. However, there are situations when it cannot do so. In particular, the following situation is fairly common:
data T a = ...

class Constraint1 a
class Constraint1 a => Constraint2 a
instance Constraint1 a => Semigroup (T a) instance Constraint2 a => Monoid (T a) @ Since Constraint1 is insufficient to implement mempty, stimes for T a cannot do so. When working with such a type, or when working polymorphically with Semigroup instances, mtimesDefault should be used when the multiplier might be zero. It is implemented using stimes when the multiplier is nonzero and mempty when it is zero.