-
Notifications
You must be signed in to change notification settings - Fork 46
Description
e.g. Nothing is not encoded as Null, the EncodeJson instance for Maybe is completely ignored when generically traversing a data structure containing a Maybe. This is because gEncodeJson' recursively invokes itself without using EncodeJson at all.
The result is, that generic encoding is very limited, because it is not possible to manually override parts of the process.
As gEncodeJson' only operates on spines, I don't really see how this can be fixed, unfortunately. Except for calling fromSpine on each recursion and checking whether there is an instance somehow and using it, if available. While this could theoretically work with some JS hackery, I believe fixing decoding is much harder, because you can not retrieve a value before having already decoded the JSON, but then it is already too late. (Except we could decode it twice if an instance is found.)
In any case - this is very hacky. Is this afterall because Haskell's generics are more powerful, that aeson does not have this problem?