-- | Extra functions for working with monoids. module Data.Monoid.Extra( module Data.Monoid, -- * Extra operations mwhen ) where import Data.Monoid -- | Like 'Control.Monad.when', but operating on a 'Monoid'. If the first argument -- is 'True' returns the second, otherwise returns 'mempty'. -- -- > mwhen True "test" == "test" -- > mwhen False "test" == "" mwhen :: Monoid a => Bool -> a -> a mwhen :: forall a. Monoid a => Bool -> a -> a mwhen Bool b a x = if Bool b then a x else a forall a. Monoid a => a mempty