Comments (7)
Personally, I think traverseVoid
is better than traverse_
. It is a contraction of traverse(_).void
and it hopefully helps the user also learn about .void
.
While traverseUnit
seems plausible, note that def unit: F[Unit]
which is a constant, while def void[A](f: F[A]): F[Unit]
is not.. so traverseUnit invites that confusion in my opinion.
Discard is also possibly nice, but if we go down that road, I think we want def discard[A](f: F[A]): F[Unit]
added to functor as a synonym for void
. Secondly, the "discard" part is just the inside value, whereas if you read discard(List(1, 2, 3))
it's not obvious that is just discarding the inside, not the entire thing (not sure why you would want that, but still, just pointing out that to someone who doesn't know the functions it may still be unclear).
In summary, my vote would be that making traverseVoid as an alias for traverse_ would be a positive move without introducing a larger question of re-litigating def void
.
from cats.
I think it's possible to offer a scalafix rewrite that could even be applied by scala-steward. This could be done together with deprecating the old methods.
from cats.
Agree, a scalafix rule could come in handy indeed. I would suggest though to address it in a separate follow-up PR, i.e.:
- Introduce aliases;
- Create the scalafix rule and deprecate the old names.
Just to let the aliases go live without awaiting the rewrite to come out. I feel we can expedite the whole process that way.
That said, I also feel that in this particular case for many users it could be way easier to do a simple "find-and-replace" across their projects rather than bother with scalafix. Especially if there's no automated process of applying scalafix rules in there (which I bet many real-world projects don't have).
from cats.
Normally I hate having multiple words for things but… yeah, the underscore variants are really weird, particularly for something so commonly used. Agreed this is worth fixing. Also we've done this in a few places in Cats Effect as well, perhaps most notably async_
(though in our defense on that one, it is the variant you probably shouldn't be using).
from cats.
As of my two cents, technically, that underscore postfix has been well-recognized and has influenced the whole ecosystem (not only the Typelevel one). We shouldn't give up on it, for sure.
But it's also true that adding a few more aliases will barely make things worse. To consider:
traverseUnit
(for newcomers, it's explicit on the return type)traverseDiscard
(for newcomers, it's explicit on the intent)traverseVoid
(for those familiar withFunctor#void
, it's explicit on the intent)
from cats.
I like traverseVoid
, too.
Here's my question: do we deprecate the old and create toil, or live with the duplicate names until the heat death of the universe and/or Cats 3?
from cats.
I think we can arrange something in the middle. For example:
- Add the aliases but do not deprecate the old method names.
- When cutting the next release, mention in the release notes, that we're going to deprecate those methods soon.
- After the next release create a follow-up PR that deprecates the old names, but do not merge it. Keep it unmerged until two or three releases get passed.
- Once we feel that the majority of downstream projects are ready, merge the PR eventually.
- Cut yet another release.
A plan like that might work, I guess.
from cats.
Related Issues (20)
- IndexedStateT has superfluous parts HOT 4
- .splitWhen
- Difference in the Applicative inferred for Seq[Seq[?]]#sequence between Scala 2 and 3
- Inconsistent behaviour when using Eval as Applicative
- `Tuple1SemigroupalOps` methods have different names from other `TupleNSemigroupalOps` classes HOT 3
- Instances for Currency HOT 7
- EitherT[Option, ?, ?]] can't be used as a bifunctor HOT 5
- trait EuclidianRing should not be a Ring HOT 4
- OutOfMemoryError when IO.uncancelable is used in recursive function HOT 1
- ambiguous implicit resolution of `Show.ContravariantShow[immutable.SortedMap[K, V]]` HOT 1
- Should Monad extend Defer? HOT 11
- Support Scala Native 0.5 HOT 3
- Adding an alternative version of the method whenA with a different signature
- `Eval` thread safety HOT 4
- Optimize `distinct`/`distinctBy` implementations for non-empty collections
- Any reason `intercalate` isn't exposed directly on the `Semigroup` companion object? HOT 3
- (very breaking) change in Future instances? HOT 5
- Reveal internal but public identifiers and make them `private[cats]`
- Cats Order needs an `orElseBy` combinator HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cats.