Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is another attempt to fix #31 (see also #32, @jeremyrsmith's PR here, and this discussion).
The key issue (which I've refined a bit in my head since opening #31) is that YAML supports a number of "Language-Independent Types" that are supported by SnakeYAML but not (currently) circe-yaml.
One missing feature is merge keys (see example in #31). Another is YAML's more lenient representation of booleans, integers, etc.:
Another (more problematic) one is timestamps. In a current Jackson-powered pipeline for working with YAML in circe, we're relying on the fact that Jackson's YAML processing transforms YAML's (kind of ridiculous) timestamp representation to epoch seconds. This is really nice in that it means that we don't have to reproduce YAML's silly rules for what counts as a timestamp for ourselves on the circe decoding side. In the current version of circe-yaml, YAML timestamps are just passed through to the JSON unchanged as strings, which means we do.
The advantage of circe-yaml's current approach is that no information (timezone, etc.) gets dropped. These YAML things are called timestamps, though, so I'm not sure I care that much about losing timezone information, and even if we only supported decoding YAML's timestamp as longs, users would still be able to put their dates in YAML strings if they really wanted the exact representation to be available in their JSON.
(We could also transform YAML timestamps into JSON strings with a single standard date format instead of epoch seconds, but the long approach has the advantage of matching what Jackson does and not making us choose the format).
What I've done in this PR is to add a new
Parser
case class with options for a few language-independent types so that users don't have to choose (or contort their YAML). By default all of the language-independent types mentioned above are enabled, but they can all be turned off if people want the old behavior.I've also taken a quick stab at fixing stack safety for deep documents with
EitherT
. I haven't tested it, and that really should have happened in a different PR, but oh well.This is just a sketch, and needs several things before it could be merged (if we decide to go this route):
Note that while this PR is source compatible with 0.6.1, it's not binary compatible (unlike the simpler version in #32).