Thanks! I finally got the decoders to work, and I'm planning to write a post about that.
El lunes, 27 de marzo de 2017, 15:24:52 (UTC+2), Murphy Randle escribió: > > Hi, Adrian! I've struggled with this myself. And I wouldn't say that I > really understand the problem well, but It seems that any time you have > mutually recursive decoders, things can get messy at this point. I've taken > your example and made more of the decoders lazy: > > https://ellie-app.com/LhJ5r5MX7ca1/0 > > Now the runtime error is gone, but the decoding fails. But hopefully that > helps! > > On Monday, March 27, 2017 at 4:37:38 AM UTC-6, Adrian Ribao wrote: >> >> Hello, >> >> I'm creating a library to manage persistence with an Elixir backend using >> Phoenix Framework. In Phoenix, invalid fields are returned like this: >> >> { "errors" : >> field_name: ["list", "of", "errors"] >> } >> >> And when you are working with nested relations, errors are like: >> >> { "errors" : >> nested_form: [ >> {name: ["Name too short"]} >> ] >> } >> >> For each field name, instead of getting a list of strings, now you get a >> dict with a list of strings. >> >> The two kind of errors may appear in the same json: >> >> { "errors" : >> field_name: ["This field is not valid"], >> nested_form: [ >> {name: ["Name too short"]} >> ] >> } >> >> I've created a recursive decoder, you can see it here: >> https://ellie-app.com/LdLVZWNJHfa1/11 >> >> But event though it compiles, using the lazy function raises a runtime >> exception. >> >> Is this a bug or I'm implementing it wrong? >> >> Thanks, >> >> Adrián >> >> -- You received this message because you are subscribed to the Google Groups "Elm Discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
