`ap` ordering is inconsistent
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 5.5k
- Forks
- 1.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 5
Description
In Apply, ap is defined like so:
def ap[A, B](ff: F[A => B])(fa: F[A]): F[B]
If we're using the generated typeclass syntax, that means user code looks like function.ap(value).
Unfortunately, when ap is explicitly defined, it's almost always defined the opposite way. For example, on Validated:
def ap[EE >: E, B](f: Validated[EE, A => B])
This gives us usage code like value.ap(function). Knowing which ordering to expect is pretty confusing: it varies depending on the data type involved and whether or not we're working with it in a generic context.
I guess since we're at 1.0 we probably can't just go and fix it, but we might be able to define an alias that's used more consistently. (ap has always felt like a bit of an odd name to me... cats usually sticks to full words for methods like this.) i have some preference for the second form: it keeps the function on the right like map and flatMap, and the type inference is better.
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 by reading the Apply typeclass and the explicit ap definition on Validated, then inspect how generated typeclass syntax exposes the method. Decide whether a compatible alias or another API change can resolve the ordering mismatch without breaking existing usage. Done would require an agreed design and consistent behavior across the affected APIs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- developer-experience
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100