-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Conversation
…A, B]` is added.
@yilinwei , thank you for the discussion and encouragement. |
Codecov Report
@@ 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 |
There was a problem hiding this 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 :)
*/ | ||
def fromState[F[_]: Applicative, A, B](s: State[A, F[B]]): StateT[F, A, B] = | ||
s.transformF { eval => | ||
import cats.implicits._ |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
…mState` for the sake of consistency with the rest of the file.
There was a problem hiding this 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.
No description provided.