input-output-hk / foliage

🌿 Foliage is a tool to create custom Haskell package repositories, in a fully reproducible way.
MIT License
42 stars 9 forks source link

Fix #11: improve parsing #57

Closed yvan-sraka closed 5 months ago

andreabedini commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

I found a related discussion on the tomland repo.

andreabedini commented 1 year ago

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

yvan-sraka commented 1 year ago

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