Remove mtimesDefault or move it to Data.Monoid

Hi! I was surprised to find two functions that appear to do the same thing in Data.Semigroup: stimesMonoid :: (Integral b, Monoid a) => b -> a -> a [1] mtimesDefault :: (Integral b, Monoid a) => b -> a -> a [2] Both are essentially versions of the default stimes implementation that allow 0 as a multiplier. I think it's confusing to have two functions with nearly the same semantics but different implementations exported from the same module. As stimesMonoid seems to fit well into the group of different stimes implementations exported from Data.Semigroup, I propose that either 1. mtimesDefault be deleted (after a suitable deprecation period) or (particularly, if there still are plans to make mtimes a member of Monoid) 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. Cheers, Simon [1] http://hackage.haskell.org/package/base-4.11.0.0/docs/Data-Semigroup.html#v:... [2] http://hackage.haskell.org/package/base-4.11.0.0/docs/Data-Semigroup.html#v:...

2018-04-07 1:11 GMT+02:00 Simon Jakobi
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
participants (1)
-
Simon Jakobi