Mojang / DataFixerUpper

A set of utilities designed for incremental building, merging and optimization of data transformations.
MIT License
1.19k stars 138 forks source link

Partial Result Handling for EitherCodec and Collections Codec #57

Open Cyborgmas opened 3 years ago

Cyborgmas commented 3 years ago

Not a specific issue, but rather a comment/critique of how partial results are handled in some cases.

The EitherCodec always tries to decode the left first, but always returns the right in the case of a partial result. This is even more problematic when the either has the same type, and is used to encode/decode in two different manners, perhaps then a concatenation of the two partials is wanted.

The collections codec that use apply2stable also have a problem, outlined in #55 , which discards entries after the first no-partial DataResult. Something else that might be worth considering is that currently the collection always has a partial result, but should it contain only contain the completely succesful elements of the collection? Or should it also contain the ones that have a partial result? Also, since they always have a partial result, even if all elements have failed completely, the collection will have an empty collection as a partial, which might not be desired.

See https://github.com/MinecraftForge/MinecraftForge/pull/7582 for the issue that arises from minecraft's use of the EitherCodec.