utility-ht-0.0.17.1: Various small helper functions for Lists, Maybes, Tuples, Functions
Safe HaskellSafe-Inferred
LanguageHaskell98

Data.Monoid.HT

Synopsis

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