1
\$\begingroup\$

I have implemented a function mcollect which is effectively mconcat only for applicative monoids:

mcollect
  :: Applicative f
  => Monoid (f a)
  => [a]
  -> f a
mcollect = mconcat . fmap pure

However I am not overly keen on the name mcollect, an alternative name in the spirit of mconcat is amconcat which I am not keen on either. Looking on Hoogle there does not appear to be anything like this in any libraries, that I can find. Does something like this exist somewhere already, I've just missed it? Is there a better name for this function?

\$\endgroup\$
1
  • \$\begingroup\$ could you clarify why lifting applicative monoids into Ap as already supported by mconcat is not sufficient for your purposes? \$\endgroup\$ Commented Feb 13, 2020 at 16:41

1 Answer 1

1
\$\begingroup\$

I wouldn't give this a name. It is equal to foldMap pure and feels to me like it might be refactored away with more context.

\$\endgroup\$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.