Comments (12)
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.
@milessabin Agreed. Here are some of the potential additional uses of cats that I've thought about:
- Make
Decoder
a value class wrapper forKleisli[Xor[DecodingFailure, ?], HCursor, ?]
and get a few of its operations from isometric instances. - Monoid up
JsonObject
etc. and get rid of the one-off:+
, etc. - Give
Cursor
and history tracking a more explicitFree
treatment. - 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.
For the record there's additional conversation on this issue in the gitter room.
from circe.
echo @milessabin concern. I am not sure how useful can circe without cats module be?
from circe.
@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.
@travisbrown I see, thanks!
from circe.
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.
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.
@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.
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.
@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.
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)
- Maximal number of successive inlines (32) exceeded, Maybe this is caused by a recursive inline method? HOT 7
- Circe cannot decode output from auto-derived codec on Scala 3 HOT 1
- Scala3 derivation incorrectly assumes collection type for generic class HOT 4
- Stack overflow on 0.14.6 HOT 4
- Unexpected derivation of Encoder[Option[T]]
- Modifying JsonObject using ACursor/HCursor performance hit due to megamorphic calls HOT 1
- Invalid Json tree with `null` (java) values, NPE in printer HOT 1
- a problem with current derivations HOT 7
- Properly parse JSON object key with quotes HOT 1
- usage of ISO_ZONED_DATE_TIME as default formatter in encoder HOT 3
- Scala 2.13: derivedConfiguratedEncoder becomes unconfigured under some conditions HOT 1
- Expected `json` string interpolator from io.circe.literal to be able to interpolate variable inside of value strings HOT 3
- Invalid pathToRoot for `missing required field` validation error HOT 3
- flaky test PointerInterpolatorSuite HOT 2
- `StackOverflowError` if local class since 0.14.7 with Scala 3 HOT 2
- Adjust contrast of website nav menu colours
- Refined version update for JS and JVM HOT 4
- Move refined into its own repo with its own release cycle
- Scala 3 Inconsistent Application of Configuration Discriminator HOT 2
- Decoder error message: loss of information HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from circe.