typelevel / cats

Lightweight, modular, and extensible library for functional programming.
https://typelevel.org/cats/
Other
5.26k stars 1.21k forks source link

alleycats - `Extract[F[_]]` the only way to get the syntax is the deprecated one #4642

Open arturaz opened 3 months ago

arturaz commented 3 months ago

image

aluscent commented 4 weeks ago

How can I resolve this issue? I like to contribute; would please provide more details? Should something be added to the documentation?

satorg commented 4 weeks ago

@aluscent , thank you for offering your help!

If you'd like to, feel free to file a PR. I'd suggest to follow the same code pattern that is used for syntaxes for Empty and Foldable type classes in alleycats.syntax: create ExtractSyntax with corresponding methods, then a new object extact extends ExtractSyntax. Also make sure that alleycats.syntax.all inherits to ExtractSyntax as well.

Personally, I'd probably also consider making trait ExtractSyntax private to the alleycats package, but since neither EmptySyntax nor FoldableSyntax in there are private, I don't have a strong opinion on that.

Also I believe that some tests that could check the new syntax works as expected would be helpful. But it looks like no one've even bothered writing tests for "alleycats", so it is up to you. But you could be the first one, if you'd like to.

aluscent commented 3 weeks ago

Dear @satorg thank you for your guidance.

I fixed the issue and added ExtractSyntax and an object extract - just like empty. I also didn't make it private according to EmptySyntax and FoldableSyntax.

Also I want to write test cases for them, but I will need some guidance again. Should I write tests for the whole alleycats-core? Where should I place them - in alleycats-core/src/test or the tests/shared/src?

satorg commented 2 days ago

@aluscent you don't have to write all the test for sure. You can if you'd like to, but I'd suggest to arrange all unrelated tests in a separate PR.

Regarding the location question – I'm not sure, to be honest. Cats uses the separate tests module for cats-core and cats-kernel, but some other modules use their own test directories for that (e.g. alleycats-laws).

I'd say it is safe to assume that we can start with alleycats-core/src/test for now unless there are objections from other members of the community.