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

Convert ReaderWriterStateT to IndexedReaderWriterStateT #1803

Merged
merged 9 commits into from
Sep 12, 2017

Conversation

iravid
Copy link
Contributor

@iravid iravid commented Aug 8, 2017

Resolves #1774, #1786.

In favour of consistency with #1775, the following has changed:

  • transformS has been added with a similar signature
  • IRWST.contramap now transforms the input state and so does the Contravariant instance, accordingly
  • IRWST.dimap now transforms the input and output states, and so does the Profunctor instance
  • IRWST.bimap and a Bifunctor instance has been added to transform the resulting output state and output value

@codecov-io
Copy link

codecov-io commented Aug 8, 2017

Codecov Report

Merging #1803 into master will increase coverage by 0.13%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1803      +/-   ##
==========================================
+ Coverage   95.35%   95.49%   +0.13%     
==========================================
  Files         248      248              
  Lines        4396     4418      +22     
  Branches      108      119      +11     
==========================================
+ Hits         4192     4219      +27     
+ Misses        204      199       -5
Impacted Files Coverage Δ
core/src/main/scala/cats/data/package.scala 87.5% <ø> (+1.78%) ⬆️
...in/scala/cats/data/IndexedReaderWriterStateT.scala 100% <100%> (ø)
...rc/main/scala/cats/laws/discipline/Arbitrary.scala 92.06% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5bb0252...0f92292. Read the comment docs.

@iravid iravid force-pushed the feature/indexed-rwst branch 4 times, most recently from bfbffdd to 2a1689e Compare August 9, 2017 06:43
@iravid
Copy link
Contributor Author

iravid commented Aug 16, 2017

All feedback appreciated, folks

@non
Copy link
Contributor

non commented Aug 31, 2017

One small thing: I think we should rename the file this is in to match its name (e.g. rename ReaderWriterStateT.scala to IndexedReaderWriterStateT.scala).

@iravid
Copy link
Contributor Author

iravid commented Aug 31, 2017

Thanks for the comment - I’ll do that once review finishes, as it makes the diffs much harder to read :-)

private[data] sealed trait RWSTInstances extends RWSTInstances1 {
implicit def catsDataProfunctorForRWST[F[_], L, S](implicit F0: Functor[F]): Profunctor[ReaderWriterStateT[F, ?, L, S, ?]] =
new RWSTProfunctor[F, L, S] {
private[data] sealed trait IRWSTInstances extends IRWSTInstances1 {
Copy link
Contributor

Choose a reason for hiding this comment

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

per #1879 do you mind change all the instance traits here into abstract class? I am creating a PR to change other classes, but don't want to touch this one to avoid conflict.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@iravid
Copy link
Contributor Author

iravid commented Sep 8, 2017

Ping. This has been sitting here for a while. Any chance we could move this forward?

Copy link
Contributor

@johnynek johnynek 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. Seems like a mechanical change. The shuffling of the methods in the functions is a bit of a pain to review, but I guess it can't be helped.

Made one comment asking if this can be an Arrow now.

*/
final class ReaderWriterStateT[F[_], E, L, S, A](val runF: F[(E, S) => F[(L, S, A)]]) extends Serializable {
final class IndexedReaderWriterStateT[F[_], E, L, SA, SB, A](val runF: F[(E, SA) => F[(L, SB, A)]]) extends Serializable {
Copy link
Contributor

Choose a reason for hiding this comment

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

it feels like this could have an Arrow[SA, SB] instance now. Am I wrong?

I don't know if it is worth it, but it if it can have an instance, it would be nice to add (same may be true for IndexedStateT).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, we can definitely do Compose and Strong.

Category (id) and Arrow (lift) are a bit more problematic. We need to conjure up the value somehow. That could work for V: Monoid.

I'll add Compose+Strong and Arrow as separate traits. Thanks for the suggestion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@johnynek Added the instances both here and in the IndexedStateT PR.

@johnynek
Copy link
Contributor

👍

@kailuowang
Copy link
Contributor

LGTM, I guess it's time to change the filenames.

@iravid
Copy link
Contributor Author

iravid commented Sep 12, 2017

Hmm, I see that coverage has decreased somehow. I'll fix that.

@iravid
Copy link
Contributor Author

iravid commented Sep 12, 2017

Ok, 100% diff coverage, we should be good to go :-)

@kailuowang kailuowang merged commit 79d154d into typelevel:master Sep 12, 2017
@kailuowang
Copy link
Contributor

Thanks so much @iravid. Sorry it dragged so long.

@iravid
Copy link
Contributor Author

iravid commented Sep 12, 2017

Thanks @kailuowang, looking forward to using this when 1.0.0-RC1 is out :-)

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.

5 participants