If you have a recursive JSON structure to decode, then the decoder either
needs to refer to itself (a cycle) or it needs to generate a new decoder on
each recursive step.

Mark


On Thu, Nov 30, 2017 at 2:43 AM, 'Rupert Smith' via Elm Discuss <
[email protected]> wrote:

>
> On Thursday, November 30, 2017 at 10:29:42 AM UTC, Rupert Smith wrote:
>>
>> I need to use Decode.lazy to do this. Is that memoized? Is that how
>> decoders can create recursive values? Other than that, I don't see how they
>> could.
>>
>
> Do you need to start with a recursive object in Javascript, then decode
> into Elm using Decode.lazy, to produce a recursive value in Elm?
>
> Approximately:
>
> var rec = { field : rec };
>
> myapp.ports.myport.send(rec);
>
>
>
> type Rec =
>
>     Rec
>     {
>         field : Rec
>     }
>
>
> port myport : (Rec -> msg) -> Sub msg
>
>
>
> But of course, that isn't going to compile as ports won't decode tagged
> union types, and you need a tagged union type to define a recursive type.
>
> --
> 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.
>

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