[Haskell-cafe] foldMap for semigroups
Henning Thielemann
lemming at henning-thielemann.de
Fri May 14 21:11:47 UTC 2021
On Fri, 14 May 2021, coot at coot.me wrote:
> Base has:
> * foldMap :: (Foldable t, Monoid a) => (x -> a) -> t x -> a
> * foldr1 :: (Foldable t) => (a -> a -> a) -> t x -> a
> Is there a good reason why it does not have:
> ```
> foldMap1 :: (Foldable t, Semigroup a, Functor f) => (a -> a) -> t x -> a
> foldMap1 = fodlr1 (<>) . fmap f
> ```
> Like `foldr1` it is partial for any foldable that can be empty.
I do not think we should extend support for partial functions.
foldMap1 should be restricted to non-empty Foldable (i.e. Foldable1).
More information about the Haskell-Cafe
mailing list