add Selective
Open
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 5.5k
- Forks
- 1.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 5
Description
https://www.staff.ncl.ac.uk/andrey.mokhov/selective-functors.pdf
trait Selective[F[_]] {
def applicative: Applicative[F] // we could also extend, but that may create ambiguities
// the law here is if you give `F[Right[B]` we never evaluate `fn`
def select[A, B](fab: F[Either[A, B]])(fn: F[A => B]): F[B]
}
object Selective {
def fromMonad[F[_]: Monad]: Selective[F] =
new Selective[F] {
def applicative = Monad[F]
def select[A, B](fa: F[Either[A, B]])(fn: F[A => B]): F[B] =
fa.flatMap {
case Right(b) => Monad[F].pure(b)
case Left(a) => fn.map(_(a))
}
}
}
Note the paper gives some interesting examples of things that don't have Monad but do have Selective, e.g. Validated.
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 selective functors paper and the existing Applicative and Monad abstractions in the Cats repository. Clarify the API and laws, including the proposed fromMonad behavior and support for Validated, then identify the tests needed to establish the design before implementation.
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