typelevel / typelevel/typelevel-scalafix
Lint for `.flatTap` with non-`Unit` result
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 27
- Forks
- 8
- PR merge metrics
- No merged PRs in 30d
Description
flatTap is defined as:
def flatTap[A, B](fa: F[A])(f: A => F[B]): F[A] =
flatMap(fa)(a => as(f(a), a))
While silently discarding an arbitrary B is convenient for ergonomics, it may be desirable to call attention to the fact you are discarding a result by requiring that B =:= Unit and thus forcing the user to call .void if their function does not return F[Unit].
This seems like a good candidate for a lint. Inspired by a Discord question, h/t @sbuzzard.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the referenced FlatMap.scala definition of flatTap, then locate the repository's existing Scalafix rule and test entry points; the issue names no implementation files or tests. Done should mean detecting flatTap calls that discard a non-Unit result while allowing F[Unit] results and the explicit .void alternative.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100