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

Optimize Alternative (part 4): add prependK/appendK specializations for Cats monad transformers #4299

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

satorg
Copy link
Contributor

@satorg satorg commented Sep 16, 2022

@satorg
Copy link
Contributor Author

satorg commented Sep 16, 2022

The PR is created as "Draft" because this work was done quite a long ago and I just want to make sure I didn't lose something after lots of merges and rebases. But perhaps it is good to go already.

@satorg satorg force-pushed the ne-alternative-specializations-montrans branch from bcc20ee to 5d7b27d Compare September 17, 2022 23:55
@satorg satorg force-pushed the ne-alternative-specializations-montrans branch from 5d7b27d to 84e4788 Compare October 3, 2022 01:17
@satorg
Copy link
Contributor Author

satorg commented Oct 9, 2022

I've made a deep inhale and re-reviewed the changes here. I would say they look good to me and seems all the tests and Mima checks are happy as well. So I would dare to claim the PR is ready to go)

@satorg satorg marked this pull request as ready for review October 9, 2022 08:03
@satorg satorg force-pushed the ne-alternative-specializations-montrans branch from 84e4788 to 6f16d4b Compare October 9, 2022 08:04
@armanbilge armanbilge added this to the 2.9.0 milestone Oct 9, 2022
@armanbilge armanbilge changed the title Optimize Alternative (part 4): add prependK/appendK specializations for Cats monad transformers Optimize Alternative (part 4): add prependK/appendK specializations for Cats monad transformers Oct 9, 2022
@satorg satorg force-pushed the ne-alternative-specializations-montrans branch 2 times, most recently from e8a4d0e to 0d3d11d Compare October 10, 2022 03:46
@satorg satorg force-pushed the ne-alternative-specializations-montrans branch 3 times, most recently from e2d015c to fbb3510 Compare October 19, 2022 02:18
@satorg
Copy link
Contributor Author

satorg commented Oct 20, 2022

I think that all the concerns have been addressed here. Could you take one more look please?

@armanbilge
Copy link
Member

Sorry, haven't forgotten. Rather than "one more look" it needs "one proper look" actually 😅

@satorg satorg force-pushed the ne-alternative-specializations-montrans branch from fbb3510 to 7c0f6b1 Compare October 28, 2022 04:44
Comment on lines -824 to +839
private trait RWSTAlternative1[F[_], E, L, S]
private trait RWSTNonEmptyAlternative1[F[_], E, L, S]
Copy link
Member

Choose a reason for hiding this comment

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

Sorry if I missed it. Did we add law tests for this instance?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, no worries, here they are:

trait NonEmptyAlternativeLaws[F[_]] extends ApplicativeLaws[F] with SemigroupKLaws[F] {

trait NonEmptyAlternativeTests[F[_]] extends ApplicativeTests[F] with SemigroupKTests[F] {

Copy link
Member

Choose a reason for hiding this comment

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

Thanks, I mean specifically for the IndexedReaderWriterStateT instance of NonEmptyAlternative.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Accordingly, AlternativeLaws and AlternativeTests were changed to extend NonEmptyAlternative*:

trait AlternativeLaws[F[_]] extends NonEmptyAlternativeLaws[F] with MonoidKLaws[F] {

trait AlternativeTests[F[_]] extends NonEmptyAlternativeTests[F] with MonoidKTests[F] {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@armanbilge is it what you're asking about?

{
implicit val G: Monad[ListWrapper] = ListWrapper.monad
val SA = IRWST.catsDataAlternativeForIRWST[ListWrapper, Boolean, String, MiniInt](ListWrapper.monad,
ListWrapper.alternative,
Monoid[String]
)
checkAll(
"IndexedReaderWriterStateT[ListWrapper, String, String, Int, Int, *]",
AlternativeTests[IRWST[ListWrapper, Boolean, String, MiniInt, MiniInt, *]](SA).alternative[Int, Int, Int]
)
checkAll("Alternative[IndexedReaderWriterStateT[ListWrapper, String, String, Int, Int, *]]",
SerializableTests.serializable(SA)
)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That part of tests was not changed, though, iirc – it included tests for NonEmptyAlternativeLaws automatically due to the inheritance.

Copy link
Member

Choose a reason for hiding this comment

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

I see, thanks. I was asking, because for the other instances you added tests using ListWrapper.nonEmptyAlternative in addition to existing tests using the ListWrapper.alternative, as far as I can tell.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I see... That's a fair concern.. And honestly, I don't remember why. There are three causes possible:

  1. I simply forgot to add it.
  2. I lost it after a series of successive rebases.
  3. Most likely, little green men came and stole that piece of code from the repo.

But I think, despite of the cause, it makes sense to return it back.

@satorg satorg force-pushed the ne-alternative-specializations-montrans branch from 7c0f6b1 to 18de9a4 Compare October 31, 2022 08:43
@satorg
Copy link
Contributor Author

satorg commented Oct 31, 2022

@armanbilge I added direct NonEmptyAlternativeLaws tests for IRWST type.
But besides that I could not refrain from cleaning that file up a little bit:

  1. class ReaderWriterStateTSuite renamed to IndexedReaderWriterStateTSuite to make it corresponding to the file name.
  2. "Organize imports" from VSCode.
  3. The test for AlternativeLaws is made looking more alike other law tests around it.
  4. Fixed compiler warnings (just in that file – yes, I did it there too!)

@satorg satorg force-pushed the ne-alternative-specializations-montrans branch from 18de9a4 to 5315b2a Compare November 1, 2022 04:38
@armanbilge armanbilge modified the milestones: 2.9.0, 2.10.0 Nov 12, 2022
@satorg satorg force-pushed the ne-alternative-specializations-montrans branch from 1f458ad to 8143774 Compare January 15, 2023 21:36
@satorg satorg force-pushed the ne-alternative-specializations-montrans branch 2 times, most recently from 629ba67 to 5e5964b Compare February 7, 2023 02:30
@satorg satorg force-pushed the ne-alternative-specializations-montrans branch from 5e5964b to e33482c Compare February 7, 2023 17:46
@satorg satorg force-pushed the ne-alternative-specializations-montrans branch from e33482c to 62328f1 Compare February 20, 2023 18:45
@satorg satorg force-pushed the ne-alternative-specializations-montrans branch 2 times, most recently from 693a260 to 7bd1e77 Compare March 27, 2023 17:22
@satorg satorg force-pushed the ne-alternative-specializations-montrans branch from 7bd1e77 to 19480c7 Compare March 31, 2023 22:26
@satorg satorg force-pushed the ne-alternative-specializations-montrans branch 3 times, most recently from e76a758 to 7b6c56a Compare May 13, 2023 05:35
@satorg satorg force-pushed the ne-alternative-specializations-montrans branch from 7b6c56a to c0c2033 Compare May 18, 2023 04:23
@satorg satorg force-pushed the ne-alternative-specializations-montrans branch from c0c2033 to 2d5208b Compare June 3, 2023 23:53
@satorg satorg force-pushed the ne-alternative-specializations-montrans branch 3 times, most recently from 871b775 to 1fc1b52 Compare June 13, 2023 07:10
@satorg
Copy link
Contributor Author

satorg commented Jun 14, 2023

Nowadays, there's a lot of hype on AI technologies around – lots of people try to ruminate on what the AI can or cannot do and how it can be useful or even dangerous to all of us.

I personally think though, that at least one of the things that the AI could really help with – is to review such huge and boring PRs like this one.

@satorg satorg force-pushed the ne-alternative-specializations-montrans branch from 1fc1b52 to f341ab7 Compare June 24, 2023 23:37
@satorg satorg force-pushed the ne-alternative-specializations-montrans branch from f341ab7 to dfa64db Compare June 26, 2023 18:40
@armanbilge
Copy link
Member

is to review such huge and boring PRs like this one.

Sorry I dropped the ball on reviewing this 😢 also I think your force-pushes erased my review progress 😅

@armanbilge armanbilge modified the milestones: 2.10.0, 2.11.0 Aug 14, 2023
@satorg
Copy link
Contributor Author

satorg commented Mar 1, 2024

Hi, @armanbilge, @johnynek ,
Sorry for the ping.
Just to confirm with you – does it make sense to maintain this PR?
Actually, I'm not asking about rushing reviewing it,
but if you think it still could be useful (somewhen later),
then I could allocate some time to actualize it – rebase on main, resolve conflicts, etc.
Otherwise, I am fine just to go close it, no problem from my side – it does not look that critical anyway.
Thanks!

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.

None yet

2 participants