Cats: Add a parallel *> and <*

Created on 6 Nov 2017  Â·  6Comments  Â·  Source: typelevel/cats

Probably two very useful operations, however giving these a good "operator name" might be fairly difficult. For now, I'll suggest something like !> and <!, but bikeshedding very welcome!

Binary Breaking enhancement in progress low-hanging fruit

Most helpful comment

>> is deprecated in favor of *> … it's an anachronism from the days before Applicative in Haskell but it's still recognizable so I think we should not have it in cats. I use <* and *> all the time but I don't know how common it is I guess … I assume lots of people are using them since they're so useful.

In any case <* and *> are also well-known from Haskell and scalaz and I think we should not change the sequential semantics. a *> b is not the same as b <* a (see State for instance) although it is for CommutativeApply and would be for Parallel with <! and !>.

All 6 comments

Why not remove *> on Applicative, just use the >> from Monad and use *> for Parallel?

@LukaJCB I think !> and <! are fine … I'm looking at Parallel for the first time and I think it should be constrained to CommutativeApply … need to review how we got here.

@etorreborre changing the constraints and semantics of *> and <* (which are heavily used) would be very disruptive so I don't think we should do that. >> is over-constrained and deprecated, and I think it's too soon to introduce it with new semantics, if this is what you were suggesting (I wasn't sure).

@tpolecat I was thinking that many people were using >> for sequencing actions. I haven't seen much code using *> instead. The net changes will be to go from >> and *> to *> and !> and I wonder if assigning just another meaning to *> would be a better move in the long run (and keep similar names between Haskell and Scala).

@tpolecat @LukaJCB feel free to ignore my bikeshedding opinion, I will be fine as long as we have an operator for Parallel.

>> is deprecated in favor of *> … it's an anachronism from the days before Applicative in Haskell but it's still recognizable so I think we should not have it in cats. I use <* and *> all the time but I don't know how common it is I guess … I assume lots of people are using them since they're so useful.

In any case <* and *> are also well-known from Haskell and scalaz and I think we should not change the sequential semantics. a *> b is not the same as b <* a (see State for instance) although it is for CommutativeApply and would be for Parallel with <! and !>.

I'm biased because I have used >> a lot more before I started using *>. And I agree with your last sentence.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Atry picture Atry  Â·  5Comments

davidabrahams picture davidabrahams  Â·  3Comments

non picture non  Â·  3Comments

durban picture durban  Â·  4Comments

SimY4 picture SimY4  Â·  4Comments