typelevel / cats-parse

A parsing library for the cats ecosystem
https://typelevel.org/cats-parse/
MIT License
233 stars 53 forks source link

Add DefaultParser and DefaultParser0 typeclasses #577

Closed morgen-peschke closed 5 months ago

morgen-peschke commented 6 months ago

These provide a way to bless canonical Parser/Parser0 instances and easily call them.

Implements #435

codecov-commenter commented 6 months ago

Codecov Report

Attention: Patch coverage is 0% with 7 lines in your changes are missing coverage. Please review.

Project coverage is 94.68%. Comparing base (1e64b32) to head (e2d540e).

Files Patch % Lines
...c/main/scala/cats/parse/extra/DefaultParser0.scala 0.00% 4 Missing :warning:
...rc/main/scala/cats/parse/extra/DefaultParser.scala 0.00% 3 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #577 +/- ## ========================================== - Coverage 95.13% 94.68% -0.45% ========================================== Files 10 12 +2 Lines 1480 1487 +7 Branches 330 332 +2 ========================================== Hits 1408 1408 - Misses 72 79 +7 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

morgen-peschke commented 6 months ago

I also wonder a bit about this typeclass being lawless.

It could be a lawful typeclass if paired with a function that converts A to String and the law is that we can always parse and get back the original.

What do you think about the lawlessness?

I don't have any strong opinions about it being lawless.

I have the mild inclination that creating laws for DefaultParser0/DefaultParser0 would imply the existence of Coparser/Coparser0, but I have no idea if that's worth representing in the code as something other than A => String.

It'd probably make testing parsers over the set of valid inputs easier, so it might be worth doing for that reason alone.

morgen-peschke commented 5 months ago

Thanks for everyone's help :)