foliage
foliage copied to clipboard
Fix #11: improve parsing
That's now how I would like to approach this. I would prefer if foliage would give a parsing error. I guess dioptional is too "powerful" and ignores all parsing failures.
I think this is a limitation of tomland. There is no way to describe a field that has a definite value type but can be missing. The only Alternative interface is at the codec level where it basically means either this codec succeeds or not. There's no "optionality" at the matcher level.
I had a go writing a "maybe" version of match, here.
Perhaps, the easiest approach could be to intercept the KeyNotFound and turn it into a success?
I found a related discussion on the tomland repo.
Marking this as draft, let me know when you think it's ready.
Seems like it does not work as expected https://github.com/input-output-hk/foliage/pull/57/checks?check_run_id=17034377725 :/