Remove mtimesDefault or move it to Data.Monoid

Simon Jakobi simon.jakobi at googlemail.com
Fri Apr 6 23:53:09 UTC 2018


2018-04-07 1:11 GMT+02:00 Simon Jakobi <simon.jakobi at googlemail.com>:
>   2. mtimesDefault be moved to Data.Monoid (possibly with a deprecated
> re-export from Data.Semigroup)
>
> In case 2, I also think mtimesDefault should be made an alias of stimesMonoid.

If we want to keep mtimesDefault, an even better idea might be to make
it use the version of stimes for the return type.

That means changing the definition from

mtimesDefault :: (Integral b, Monoid a) => b -> a -> a
mtimesDefault n x
  | n == 0    = mempty
  | otherwise = unwrapMonoid (stimes n (WrapMonoid x))

to

mtimesDefault :: (Integral b, Monoid a) => b -> a -> a
mtimesDefault n x
  | n == 0    = mempty
  | otherwise = stimes n x


Sorry for not thinking this through in the first place.

Simon


More information about the Libraries mailing list