New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ADT subtype codec is incompatible with ADT codec #17
Comments
Well, I'm unsure whether and ADT subtype codec should be compatible with the ADT codec. The reason for the error you are seeing in your snippet above is that, in release 0.8.0, ADTs are encoded as a two element array, with the type-id being the first element and the result of the subtype encoder being the second element. With map-based codecs this could be done in a way that makes the ADT encoding compatible with the subtype encoding, by adding a "special" map member (like NOTE: In 0.9.0 the ADT encoding will change from a 2-element array to a single-element map, with the typeid becoming the map key and the subtype encoding becoming this key's map value. |
I should not have used the word incompatible, as you explain the codecs are invariant. It just felt wrong that Tiger is being encoded slightly differently based on its static type within an ADT. In comparison, saw the upickle docs (see IntOrTuple example) where they always produce the typehint if a type is part of an ADT and it felt like a right choice. Either Array or Map based encoding for the ADT is fine for me. |
Yes, @mushtaq, thank you for the pointer to upickle. However, IMHO this is just "accidental", because a map-based encoding does indeed allow for detecting superfluous members and simply skipping them. So, IMHO the cleanest solution is to simply make clear (in the docs as well) that an |
Test
Exception
Workaround
The text was updated successfully, but these errors were encountered: