Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Foldable foldRight for Traverse and TraverseFilter. #3015

Merged
merged 1 commit into from
Nov 6, 2019

Conversation

takayahilton
Copy link
Contributor

Now

scala> Chain(1, 2, 3, 4, 5, 6).traverse { x => println(x); if(x > 2) Left("err") else Right(x)  }
6
5
4
3
2
1
res: scala.util.Either[String,cats.data.Chain[Int]] = Left(err)

scala> List(1, 2, 3, 4, 5, 6).traverseFilter { x => println(x); if(x > 2) Left("err") else Right(Option(x))  }
6
5
4
3
2
1
res: scala.util.Either[String,List[Int]] = Left(err)

After

scala> Chain(1, 2, 3, 4, 5, 6).traverse { x => println(x); if(x > 2) Left("err") else Right(x)  }
1
2
3
res: scala.util.Either[String,cats.data.Chain[Int]] = Left(err)

scala> List(1, 2, 3, 4, 5, 6).traverseFilter { x => println(x); if(x > 2) Left("err") else Right(Option(x))  }
1
2
3
res: scala.util.Either[String,List[Int]] = Left(err)

@kailuowang
Copy link
Contributor

Sorry Luka, I didn't mean to request your review, misclicked.

@kailuowang kailuowang self-requested a review August 28, 2019 14:34
@travisbrown travisbrown self-requested a review November 6, 2019 09:10
Copy link
Contributor

@travisbrown travisbrown left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At a glance I was surprised this is stack-safe, but I checked and it seems to be. Looks reasonable to me.

@travisbrown travisbrown added this to the 2.1.0-RC1 milestone Nov 6, 2019
@LukaJCB LukaJCB merged commit ed73246 into typelevel:master Nov 6, 2019
@takayahilton takayahilton deleted the use-foldable-foldRight branch November 6, 2019 11:07
gagandeepkalra added a commit to gagandeepkalra/cats that referenced this pull request Feb 29, 2020
gagandeepkalra added a commit to gagandeepkalra/cats that referenced this pull request Feb 29, 2020
…r List to use `foldRight` from Foldable
travisbrown pushed a commit that referenced this pull request Mar 11, 2020
travisbrown pushed a commit that referenced this pull request Mar 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants