Proposal: `unique` and `option`-alike combinators
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
Research direction
Start by reading FNested2SyntaxOps and the linked Doobie query implementation to understand the proposed unique and option behaviors. Review the 11-comment discussion before deciding whether the API and names are settled; done means an agreed design and implementation of both combinators, with validation of their exact semantics.
Written by the indexing model from the issue text.
Description
Inspired by Doobie's unique and option queries:
In fact, those two are pretty common use cases: after receiving a collection of items from somewhere, we may want to make sure that there's either exactly 1 or at most 1 items received.
To make them generally available, we could consider adding two combinators to FNested2SyntaxOps:
final class FNested2SyntaxOps[F[_], G[_], A](private val fga: F[G[A]]) extends AnyVal {
...
def uniqueOrRaise[E](e: E)(implicit F: MonadError[F, E], G: Foldable[G]): F[A] = ???
def optionOrRaise[E](e: E)(implicit F: MonadError[F, E], G: Foldable[G]): F[Option[A]] = ???
}
The proposed names may not be perfect – just got borrowed them from Doobie. However, I'm absolutely open for bikeshedding.
If such combinators make sense, I'll be glad to file a PR.
- Dominant language
- Scala
- Stars
- 376
- Forks
- 66
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 3
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.
More from typelevel/mouse
-
Difficulty 5/5 Over a week Newbie friendliness 15/100
-
RFC
Difficulty 5/5 Over a week Newbie friendliness 20/100
-
Scala 3 migration Open
Difficulty 5/5 Over a week Newbie friendliness 20/100
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
typelevel/sbt-typelevel#929 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
softwaremill/tapir#5542 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
lichess-org/lila#21793 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
apache/pekko-projection#635 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100