Cats: Rename `followedBy` and `effectFor`

Created on 20 Oct 2017  路  7Comments  路  Source: typelevel/cats

The Apply typeclass has aliases for <* and *> as effectFor and followedBy respectively. This doesn't really make sense, whenever you think about their application and I think the names detract from the actual definitions.

Consider this example:

> val x = List(1,2,3) followedBy List(4,5,6) 
x: List[Int] = List(4, 5, 6, 4, 5, 6, 4, 5, 6)

The name followedBy would seem to imply concatenation.

effectFor is a little better, since it actually expresses the application of effects. However the analogue method being followedBy makes things more confusing.

My personal preference is for there to be no named aliases here, but I understand some people don't feel that way. I can't think of any better names though. Thoughts?

Most helpful comment

<*> = ap
*> = apR
<* = apL

Although my preference would probably be no name at all

All 7 comments

I would welcome better names, but I'm also coming up short with actually coming up with any. I don't think these are important enough to include in RC1 though.

fillRight for <* and fillLeft for *> are relatively intuitive, since you're 'filling' each entry of the target applicative with a copy of the initial. I agree they don't have easily associated names. Maybe they don't need one.

I would like to keep these as is. No English word will be perfect for these abstract concepts. Some applicative will be natural one way others another. I鈥檇 rather just keep it stable and tell people bothered to use the symbols.

@johnynek I'm fine with words that don't perfectly describe the action. But methods which are analogous should have similar names (if they're going to have names at all). effectFor and followedBy aren't similar at all, and both convey very different ideas. However, what they _do_ is almost identical.

I don't think leaving things as is just for the sake of compatibility makes sense. If new names are introduced, the old ones will be deprecated (but still available for awhile) and people will move forward with little hassle; just a find and replace.

Do we like any of these:
sequenceLeft / sequenceRight
sequenceDiscardLeft / sequenceDiscardRight
sequenceKeepLeft / sequenceKeepRight
effectForLeft / effectForRight
?

<*> = ap
*> = apR
<* = apL

Although my preference would probably be no name at all

@SystemFw this works for me. Any English name is going to be substandard. Name it something that recalls some other gibberish we all know, instead of some counter-intuitive abomination.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

LukaJCB picture LukaJCB  路  3Comments

adelbertc picture adelbertc  路  5Comments

tg44 picture tg44  路  4Comments

LukaJCB picture LukaJCB  路  3Comments

durban picture durban  路  4Comments