utility-ht-0.0.17.2: Various small helper functions for Lists, Maybes, Tuples, Functions

Safe Haskell | Safe-Inferred
Language | Haskell98

Data.Monoid.HT

Synopsis

- cycle :: Monoid m => m -> m
- (<>) :: Monoid m => m -> m -> m
- when :: Monoid m => Bool -> m -> m
- power :: Monoid m => Integer -> m -> m

# Documentation

cycle :: Monoid m => m -> m Source #

Generalization of `cycle` to any monoid.

(<>) :: Monoid m => m -> m -> m infixr 6 Source #

Infix synonym for `mappend`.

when :: Monoid m => Bool -> m -> m Source #

    \b m -> when b m == mfilter (const b) (m::Maybe Ordering)

    \b m -> when b m == mfilter (const b) (m::String)

power :: Monoid m => Integer -> m -> m Source #

    QC.forAll (QC.choose (0,20)) $ \k xs -> power (fromIntegral k) xs == mconcat (replicate k (xs::String))

In contrast to `powerAssociative` the `power` function uses `mempty` only for the zeroth power.

    QC.forAll (QC.choose (0,20)) $ \k xs -> power k xs == powerAssociative mappend mempty (xs::String) k