typelevel / typelevel/cats

ApplicativeError's `orElse` should accept widening?

Open
#2,375 2 comments 0 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

With the exception of the new (as of Cats 1.2) orElse in ApplicativeError, most other places (including in the Cats library) that have an orElse allow the widening of its second parameter.

The traditional signature of an orElse for ApplicativeError would be

def orElse[AA >: A](other: ⇒ F[AA])(implicit F: ApplicativeError[F, E]): F[AA]

This is currently preventing me from upgrading to Cats 1.2, because my own orElse is no longer being picked up. I don't find any discussion of using this uncommonly restrictive signature in #2243: was this just an accidental oversight. I wanted to trigger the discussion about whether the Cats signature was wrong before I go work around this in my own code.

I'm not sure if this change can be made without breaking binary compatibility, but I can submit a PR if there's interest. I think the current signature is undesirable.

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 with the ApplicativeError.orElse signature described in the issue and compare it with the widening signatures for Validated and Either. Check whether changing the second parameter to accept a supertype preserves binary compatibility; done means the API decision is resolved and the Cats 1.2 behavior no longer blocks the reported upgrade.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
backend-api-design
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.