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

Extend Functor implementation in the Traverse instance of EitherT, OptionT and Tuple2K #2191

Merged
merged 6 commits into from
May 3, 2018
Merged

Extend Functor implementation in the Traverse instance of EitherT, OptionT and Tuple2K #2191

merged 6 commits into from
May 3, 2018

Conversation

barambani
Copy link
Contributor

This is about using the Functor instance in Traverse for the monad transformers EitherT and OptionT and in Tuple2K so to use its map implementation. This follows @peterneyens 's comment #2182 (comment) related to WriterT.

@kailuowang
Copy link
Contributor

this breaks binary compatibility. unfortunately these traits were not sealed. We might need to extend the functor trait at the instance creation site, rather than the traits.

@barambani
Copy link
Contributor Author

Thanks for the pointer, I was trying funny things. I will keep trying that way and see if I can make it keep the binary compatibility. Otherwise I will close it.

@codecov-io
Copy link

codecov-io commented Mar 13, 2018

Codecov Report

Merging #2191 into master will increase coverage by 0.22%.
The diff coverage is 89.47%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2191      +/-   ##
==========================================
+ Coverage   94.73%   94.95%   +0.22%     
==========================================
  Files         330      333       +3     
  Lines        5582     5787     +205     
  Branches      209      222      +13     
==========================================
+ Hits         5288     5495     +207     
+ Misses        294      292       -2
Impacted Files Coverage Δ
core/src/main/scala/cats/data/Kleisli.scala 96.9% <ø> (-0.99%) ⬇️
...in/scala/cats/data/IndexedReaderWriterStateT.scala 99.04% <100%> (-0.02%) ⬇️
core/src/main/scala/cats/data/EitherK.scala 93.47% <100%> (-4.35%) ⬇️
core/src/main/scala/cats/data/OptionT.scala 97.46% <100%> (ø) ⬆️
core/src/main/scala/cats/data/Nested.scala 94.28% <100%> (-1.43%) ⬇️
core/src/main/scala/cats/data/WriterT.scala 91.37% <100%> (ø) ⬆️
core/src/main/scala/cats/data/IorT.scala 97.76% <100%> (ø) ⬆️
core/src/main/scala/cats/data/EitherT.scala 97.65% <66.66%> (+0.05%) ⬆️
core/src/main/scala/cats/data/Tuple2K.scala 90.69% <83.33%> (-4.66%) ⬇️
... and 20 more

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 6b01eda...a178ec5. Read the comment docs.

kailuowang
kailuowang previously approved these changes Mar 13, 2018
@peterneyens
Copy link
Collaborator

peterneyens commented Mar 13, 2018

Thanks for the follow up.

I think we can do something similar (if you are interested) for :

  • EitherT: Bitraverse we can override bimap.
  • Tuple2K : ContravariantMonoidal extend Contravariant (can drop its contamap definition).
  • RWST: Alternative extend SemigroupK
  • IorT: Traverse extends Functor

I might have missed some other opportunities.

@barambani
Copy link
Contributor Author

Sure, I'm happy to cover as much as I can. I will give a look. Thanks for the great support


override def unit: WriterT[F, L, Unit] = WriterT(F0.trivial[(L, Unit)])

override def contramap[A, B](fa: WriterT[F, L, A])(f: B => A): WriterT[F, L, B] =
WriterT(F0.contramap(fa.run)((d: (L, B)) => (d._1, f(d._2))))
super[WriterTContravariant].contramap(fa)(f)
Copy link
Contributor Author

@barambani barambani Mar 14, 2018

Choose a reason for hiding this comment

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

I couldn't find a way to remove this. If I do it I get this

[error]  * in current version, classes mixing cats.data.WriterTContravariantMonoidal needs to update body of method contramap(cats.data.WriterT,scala.Function1)cats.data.WriterT
[error]    filter with: ProblemFilters.exclude[UpdateForwarderBodyProblem]("cats.data.WriterTContravariantMonoidal.contramap")

from Mima. @kailuowang , @peterneyens can you think to anything I can try ? Thanks a lot

@barambani
Copy link
Contributor Author

There is still a problem with IndexedReaderWriterStateT as most of the derivations are inside sealed abstract class so I cannot compose with mixin. An option could be change them to trait (even though I'm not sure if it break the compatibility), but involving IRWSTFunctor the change will affect most of the instances so I wanted to double check here before trying it. Do you see it as feasible ? Thanks a lot for the help.

@barambani
Copy link
Contributor Author

I'm not sure what happened with this build, it looks like it was killed. Do I have any way to restart the CI ? Thanks

@barambani
Copy link
Contributor Author

barambani commented Mar 27, 2018

Could the CI be reran ? Thanks

@barambani
Copy link
Contributor Author

This has been quiet for a while. I think I changed any case I could find. It should be ready for a review. Many thanks.

@LukaJCB
Copy link
Member

LukaJCB commented Apr 23, 2018

Sorry for not reviewing sooner, this looks good to me, apart from the one snippet in WriterTContravariant that you mentioned 👍 Thanks very much! :)

@barambani
Copy link
Contributor Author

No problem at all 😄 , thank you. I will see if I can do something then.

@kailuowang
Copy link
Contributor

Thanks so much! sorry about the delay.

@barambani
Copy link
Contributor Author

No worries. Thank you all 👍

@kailuowang kailuowang merged commit eba9a59 into typelevel:master May 3, 2018
@kailuowang kailuowang added this to the 1.2 milestone May 30, 2018
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