typelevel / typelevel/cats

Optimize or remove reduceMapM?

Open
#3,200 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
5.5k
Forks
1.2k
Avg merge
2d 10h
Merged PRs (30d)
5

Description

We currently have foldMapA and foldMapM methods with identical semantics (apart from the constraint), because the monadic implementation using tailRecM can be much faster than the implementation that can only use Applicative.

We've recently added a reduceMapA with a similarly loosened constraint (see #3141, #3150, and #3199). Right now reduceMapM and reduceMapA have identical implementations. It's probably the case that reduceMapM could be implemented more efficiently using tailRecM, and we should either do this or deprecate it, because otherwise there's no reason for it to exist and it's just confusing.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the implementations and constraints of foldMapA, foldMapM, reduceMapA, and reduceMapM, then read the linked tailRecM performance discussion and referenced issues #3141, #3150, and #3199. Done means resolving whether reduceMapM should use the faster monadic approach or be deprecated, with the corresponding implementation or API change completed.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
tooling
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.