cats icon indicating copy to clipboard operation
cats copied to clipboard

Add doctest example for Op in cats core

Open QueenJcloud opened this issue 2 months ago • 8 comments

This pull request adds a doctest for the Op type in cats.core. The doctest provides a simple usage example demonstrating how Op can be used for contravariant composition.

QueenJcloud avatar Oct 20 '25 12:10 QueenJcloud

Thanks for the PR! The CI failed due to a formatting issue, try running scalafmtAll in sbt.

armanbilge avatar Oct 20 '25 17:10 armanbilge

I think it would be nice if it would be possible to explain in the docs why someone may want/need this Op class in the first place. It seems there's no documentation for Op available in Cats whatsoever (or it is not that easy to find).

The class was introduced in #2217 (Add dual categories). As far as I concerned, the "Dual Category" term comes from "Category Theory" and in a nutshell refers to an ability to flip the direction of an arrow.

But it doesn't explain why someone may need this class specifically, because its compose depends on Compose which in turn already has a reversed operation andThen (and also provides handy >>> and <<< operators whereas Op doesn't).

satorg avatar Oct 20 '25 22:10 satorg

I think it would be nice if it would be possible to explain in the docs why someone may want/need this Op class in the first place. It seems there's no documentation for Op available in Cats whatsoever (or it is not that easy to find).

The class was introduced in #2217 (Add dual categories). As far as I concerned, the "Dual Category" term comes from "Category Theory" and in a nutshell refers to an ability to flip the direction of an arrow.

But it doesn't explain why someone may need this class specifically, because its compose depends on Compose which in turn already has a reversed operation andThen (and also provides handy >>> and <<< operators whereas Op doesn't).

I’ve addressed both feedback, ran scalafmtAll to fix the formatting issues, and added documentation explaining the purpose and usage of the Op class. Kindly take a look when you can and let me know if there’s anything else I should adjust or the next steps. Thank you

QueenJcloud avatar Oct 21 '25 12:10 QueenJcloud

Thanks for the PR! The CI failed due to a formatting issue, try running scalafmtAll in sbt.

I’ve addressed both feedback, ran scalafmtAll to fix the formatting issues, and added documentation explaining the purpose and usage of the Op class. Kindly take a look when you can and let me know if there’s anything else I should adjust or the next steps. Thank you

QueenJcloud avatar Oct 21 '25 12:10 QueenJcloud

Hi @satorg,

I just saw that the CI flagged a missing header for Op.scala, but all tests passed successfully. I’ll wait for your feedback before making any further changes, just to be sure I handle it correctly. Please let me know the next step when you can. Thanks!

QueenJcloud avatar Oct 22 '25 15:10 QueenJcloud

hello @satorg,

I have made corrections as per the headercheck. Please kindly check and let me know the next step when you can. Thanks!

QueenJcloud avatar Oct 22 '25 18:10 QueenJcloud

Hi @satorg, can you please recheck and let me know...Thanks.

QueenJcloud avatar Oct 23 '25 08:10 QueenJcloud

Thank you!

You’re welcome! Glad to make the update, thank you for reviewing!

QueenJcloud avatar Oct 24 '25 09:10 QueenJcloud