Add Priority / OrElse implicit search helper
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 5.5k
- Forks
- 1.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 5
Description
Samples:
- https://github.com/typelevel/algebra/blob/master/core/src/main/scala/algebra/Priority.scala
- https://github.com/milessabin/shapeless/blob/master/core/src/main/scala/shapeless/orelse.scala
I've also encountered cases in which I wished to have this helper available with the Async / Concurrent type classes in Cats-Effect. So it would work like this:
- if a
Concurrentinstance is in scope, build a cancelable task viaConcurrent.cancelable - if only an
Asyncinstance is in scope, as a fallback, build an atomic task viaAsync.async
So this is a mechanism for optimizing the implementation in case a type class instance is available, or otherwise use the default. This optimization problem is also relevant for Haskell: https://stackoverflow.com/questions/44250854/use-specialized-implementation-if-a-class-instance-is-available
I think it's time we add something like this to cats-kernel.
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 linked Priority.scala and shapeless/orelse.scala examples, then compare the proposed Concurrent.cancelable and Async.async fallback behavior with the cats-kernel scope. Done would require an agreed API design for an implicit search helper and a clear decision on whether this belongs in cats-kernel.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100