dhall-golang icon indicating copy to clipboard operation
dhall-golang copied to clipboard

Example or docs for unmarshalling into a Go interface (or workarounds for the same)

Open weberc2 opened this issue 5 years ago • 4 comments

I'm trying to unmarshal a type into a Go interface (type Arg interface { visitArg(argVisitor) error }); however, dhall-golang (understandably) doesn't know how to decode Dhall types into the Go interface. I was expecting something like the json.Unmarshaler interface that I could use to help dhall-golang figure out how to unmarshal to the proper type; however, I'm not seeing that sort of interface in the godoc pages or elsewhere. If someone could point me in the right direction, it would be appreciated. Also, it would probably be good to mention the solution in the docs somewhere.

weberc2 avatar Jul 21 '20 21:07 weberc2

Thanks for the report! Can you give an example of what it looks like in json, and how you think it might work in dhall? I'm not sure I fully understand.

philandstuff avatar Jul 22 '20 20:07 philandstuff

Worth saying: I think there is a missing feature here but I want to solicit feedback about what problems people have and what solutions might work.

philandstuff avatar Jul 22 '20 20:07 philandstuff

Yeah, sure. Here's a contrived example of how I would solve the problem in JSON: https://play.golang.org/p/DdHaLSDF_iw

I'm happy to answer questions if that's unclear.

weberc2 avatar Jul 22 '20 21:07 weberc2

Would something like https://github.com/philandstuff/dhall-golang/pull/51/files#diff-6dc6f145fee99532de7783d273cc747f be a suitable solution for you?

philandstuff avatar Jul 24 '20 13:07 philandstuff