Ah. Dammit. It must have been late. I had put in a JS object, gotten
another error, and thought it was because of the same problem.

Then, subsequently, how do I write the childrenDecoder for a recursive
model?

I'm doing the customDecoder, but I'm getting the error: "TypeError: Cannot
read property 'tag' of undefined"

childrenDecoder : Decoder Children
> childrenDecoder =
>   customDecoder
>     (Json.list nodeDecoder)
>     (\children -> Result.Ok <| Children children)


This seems like it makes sense. a customDecoder run identifies children as
a Json.list of nodeDecoders, and when we get the list of decoders, we put
it into Children, and wrap it in Result.

When looking at where the error points to, it looks like it's a large
switch statement where the JSON decoder is looking for the decoder's tag,
in order to figure out what to do next. I'm guessing that as a
customDecoder, there's no tag, and hence it's failing out.

I feel like I'm not getting exactly what to do in the case of a recursive
model.

Wil

On Wednesday, October 5, 2016 at 9:08:48 AM UTC-7, Max Goldstein wrote:
>
> To clarify Rupert: try removing the JSON.stringify call. Elm expects
> actual objects, not a string representation of objects. I think.

-- 
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.

Reply via email to