GithubHelp home page GithubHelp logo

Remove cats from core? about circe HOT 12 CLOSED

circe avatar circe commented on July 22, 2024
Remove cats from core?

from circe.

Comments (12)

milessabin avatar milessabin commented on July 22, 2024

Only possible issue I see is if you were planning to rely more on cats in the very core of circe. That would make this a bit more complicated.

My main concern is that it's quite likely that further developments would make more use of Cats, which would then be forced into the Cats submodule. The net result would be that we would be back to where we are now but with dependencies on two modules rather than one and the additional complexity of attempting to split functionality across an arbitrary boundary.

from circe.

travisbrown avatar travisbrown commented on July 22, 2024

@milessabin Agreed. Here are some of the potential additional uses of cats that I've thought about:

  1. Make Decoder a value class wrapper for Kleisli[Xor[DecodingFailure, ?], HCursor, ?] and get a few of its operations from isometric instances.
  2. Monoid up JsonObject etc. and get rid of the one-off :+, etc.
  3. Give Cursor and history tracking a more explicit Free treatment.
  4. If cats someday included a tree structure with keyed branching, use that instead of JsonObject (maybe unrealistic since it would also need to track insertion order, etc.).

So far none of these ideas seem like deal-breakers, but I'd be interested in collecting others.

from circe.

travisbrown avatar travisbrown commented on July 22, 2024

For the record there's additional conversation on this issue in the gitter room.

from circe.

ngbinh avatar ngbinh commented on July 22, 2024

echo @milessabin concern. I am not sure how useful can circe without cats module be?

from circe.

travisbrown avatar travisbrown commented on July 22, 2024

@ngbinh Many (most?) use cases wouldn't require the circe-cats module.

See for example @vkostyukov's new example Finch + circe project here. It uses circe's Shapeless-powered codec derivation and (indirectly through finch-circe) circe-jawn, but it would look literally exactly the same if #28 gets merged.

I think cats is fantastic (maybe that's obvious 😄), and I'm looking forward to adding a cats dependency to Finch, where it will allow us to clean up a lot of code. I just don't see the same kind of value in a cats dependency for circe-core.

from circe.

ngbinh avatar ngbinh commented on July 22, 2024

@travisbrown I see, thanks!

from circe.

travisbrown avatar travisbrown commented on July 22, 2024

My current thinking on this is that we move forward in this direction (cats in a module) as an experiment, but make it clear in the README that cats might be reintroduced into core at some point before 1.0 (or 0.5 or some other earlier cut-off if we think that would be better).

Any objections?

from circe.

travisbrown avatar travisbrown commented on July 22, 2024

One other area where cats would be useful in core is for applicative decoding. I really like the support that Play JSON provides for accumulating errors, and it'd be a nice addition here, but it would be a lot more laborious without a NonEmptyList and syntax for working with applicatives.

from circe.

alexarchambault avatar alexarchambault commented on July 22, 2024

@travisbrown I agree that accumulating errors would nice, and that it would be somehow painful to write without the help of cats.

But what could be even nicer would be to be able to choose whether decoding should stop at first error (as it does currently, within the lines of argonaut) or collect all errors that can be. (This could even be done on a type-by-type basis, some stopping at first errors, and others collecting them all.)

In the latter scenario, it feels to me that we would have to get our hands dirty anyway, and that cats would not be of much help here (just a beforehand intuition though...).

from circe.

alexarchambault avatar alexarchambault commented on July 22, 2024

The changes I talk about in my previous comment are a bit speculative for now. I don't mind putting the possible split of the core module (into core and cats modules) on hold for now, and the one you're talking about (error accumulation) being given a try.

from circe.

travisbrown avatar travisbrown commented on July 22, 2024

@alexarchambault I could imagine having apply on Decoder return a Validated with accumulated errors, with a new method providing a fast-failing Xor result for cases where you've got something like a large Map[String, Something] in your target type and don't need all the errors.

My conference marathon ended last night, so I'll put together a pull request this morning and we can see if we think it justifies the dependency.

from circe.

travisbrown avatar travisbrown commented on July 22, 2024

We've finally merged error accumulation, only four months after my last comment promising it immediately. 😄

Given that this work depends heavily on cats.data.Validated, I don't think removing cats from core is really an option any more (and it's also not as easy to motivate now that Argonaut is Scalaz-free).

from circe.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.