:: Monoid m => Bool -> m -> m package:relude

Returns the given value in case of the given predicate is satisfied (is True). Otherwise, it returns mempty.
>>> memptyIfFalse True (Just "Hello")
Just "Hello"

>>> memptyIfFalse False "Doesn't matter"
""
Returns the given value in case of the given predicate is unsatisfied (is False). Otherwise, it returns mempty.
>>> memptyIfTrue True (Just "Hello")
Nothing

>>> memptyIfTrue False "Does matter"
"Does matter"
This is a valid definition of stimes for an idempotent Monoid. When x <> x = x, this definition should be preferred, because it works in <math> rather than <math>
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.
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.

Examples

>>> mtimesDefault 0 "bark"
[]
>>> mtimesDefault 3 "meow"
"meowmeowmeow"
The value of seq a b is bottom if a is bottom, and otherwise equal to b. In other words, it evaluates the first argument a to weak head normal form (WHNF). seq is usually introduced to improve performance by avoiding unneeded laziness. A note on evaluation order: the expression seq a b does not guarantee that a will be evaluated before b. The only guarantee given by seq is that the both a and b will be evaluated before seq returns a value. In particular, this means that b may be evaluated before a. If you need to guarantee a specific order of evaluation, you must use the function pseq from the "parallel" package.