Skip to content

Convert ReaderWriterStateT to IndexedReaderWriterStateT - #1803

Merged
kailuowang merged 9 commits into
typelevel:masterfrom
iravid:feature/indexed-rwst
Sep 12, 2017
Merged

Convert ReaderWriterStateT to IndexedReaderWriterStateT#1803
kailuowang merged 9 commits into
typelevel:masterfrom
iravid:feature/indexed-rwst

Conversation

@iravid

@iravid iravid commented Aug 8, 2017

Copy link
Copy Markdown
Contributor

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

@iravid
iravid force-pushed the feature/indexed-rwst branch from 5fd991e to c90849c Compare August 8, 2017 21:05
@codecov-io

codecov-io commented Aug 8, 2017

Copy link
Copy Markdown

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

iravid commented Aug 16, 2017

Copy link
Copy Markdown
Contributor Author

All feedback appreciated, folks

@non

non commented Aug 31, 2017

Copy link
Copy Markdown
Contributor

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

iravid commented Aug 31, 2017

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

@iravid

iravid commented Sep 8, 2017

Copy link
Copy Markdown
Contributor Author

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

@johnynek johnynek left a comment

Copy link
Copy Markdown
Contributor

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.

* and `IndexedStateT[F, SA, SB, A]`.
*/
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

@iravid
iravid force-pushed the feature/indexed-rwst branch from ec240cf to 0870bdd Compare September 11, 2017 13:34
@johnynek

Copy link
Copy Markdown
Contributor

👍

@kailuowang

Copy link
Copy Markdown
Contributor

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

@iravid
iravid force-pushed the feature/indexed-rwst branch from 0870bdd to 893c4b6 Compare September 12, 2017 04:42
@iravid

iravid commented Sep 12, 2017

Copy link
Copy Markdown
Contributor Author

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

@iravid

iravid commented Sep 12, 2017

Copy link
Copy Markdown
Contributor Author

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

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

Copy link
Copy Markdown
Contributor

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

@iravid

iravid commented Sep 12, 2017

Copy link
Copy Markdown
Contributor Author

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