foliage icon indicating copy to clipboard operation
foliage copied to clipboard

Fix #11: improve parsing

Open yvan-sraka opened this issue 2 years ago • 5 comments

yvan-sraka avatar Apr 26 '23 14:04 yvan-sraka

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.

andreabedini avatar Apr 27 '23 05:04 andreabedini

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?

andreabedini avatar Apr 27 '23 07:04 andreabedini

I found a related discussion on the tomland repo.

andreabedini avatar Apr 27 '23 08:04 andreabedini

Marking this as draft, let me know when you think it's ready.

andreabedini avatar Aug 11 '23 05:08 andreabedini

Seems like it does not work as expected https://github.com/input-output-hk/foliage/pull/57/checks?check_run_id=17034377725 :/

yvan-sraka avatar Sep 22 '23 11:09 yvan-sraka