Open
Description
Brand new sum codecs made by @m-bock make writing sum type codecs a breeze. But there is a problem with decoding error reports that in most cases happen to be are irrelevant.
For example, for this type
data Sample
= Foo
| Bar Int
| Baz Boolean String Int
When parsing (wrong value type):
$ Str.joinWith "\n"
[ "{"
, " \"tag\": \"Bar\","
, " \"values\": \"42\""
, "}"
]
the error reported is: (Named "Sample" (TypeMismatch "Expecting tag Baz, got Bar"))
. However, one would expect to see something like this: (Named "Sample" (Named "case Bar" (TypeMismatch "Int")))
This is because it currently propagates decoding errors for all cases (without respect to the actual tag value) and reports the error for the last case.
To solve this I refactored the code a bit and added tests for error reporting, going to make a PR.