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

A method StateT.fromState turning State[A, F[B]] into StateT[F,A, B] is added. #3524

Merged
merged 2 commits into from
Jul 21, 2020

Conversation

akopich
Copy link
Contributor

@akopich akopich commented Jul 18, 2020

No description provided.

@akopich
Copy link
Contributor Author

akopich commented Jul 18, 2020

@yilinwei , thank you for the discussion and encouragement.

@codecov-commenter
Copy link

Codecov Report

Merging #3524 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #3524   +/-   ##
=======================================
  Coverage   91.33%   91.33%           
=======================================
  Files         386      386           
  Lines        8588     8591    +3     
  Branches      252      260    +8     
=======================================
+ Hits         7844     7847    +3     
  Misses        744      744           

LukaJCB
LukaJCB previously approved these changes Jul 19, 2020
Copy link
Member

@LukaJCB LukaJCB left a comment

Choose a reason for hiding this comment

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

Thanks, this seems useful :)

travisbrown
travisbrown previously approved these changes Jul 21, 2020
*/
def fromState[F[_]: Applicative, A, B](s: State[A, F[B]]): StateT[F, A, B] =
s.transformF { eval =>
import cats.implicits._
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a minor thing, but we've been moving away from using Cats syntax in the core Cats implementation, in part because some cases had been causing issues on Dotty, but also because avoiding it makes runtime and compile-time performance a little more predictable. In this case I think the desugared version doesn't lose much readability:

def fromState[F[_], A, B](s: State[A, F[B]])(implicit F: Applicative[F]): StateT[F, A, B] =
  s.transformF { eval =>

    val (a, fb) = eval.value
    F.map(fb)((a, _))
  }

This definitely shouldn't block the PR, though, and I'd be happy to see it merged as-is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing that out. I'll desugar that. At least, for the sake of consistency with the rest of the file.

@akopich akopich dismissed stale reviews from travisbrown and LukaJCB via 7ff0156 July 21, 2020 10:25
…mState` for the sake of consistency with the rest of the file.
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.

Looks good to me! I'll merge when green since the changes are minor and I don't think they should invalidate the earlier review.

@travisbrown travisbrown added this to the 2.2.0-RC2 milestone Jul 21, 2020
@travisbrown travisbrown merged commit 84f20ef into typelevel:master Jul 21, 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