On Monday, November 27, 2017 at 9:06:38 PM UTC, Mark Hamburg wrote:
>
> Recursive decoders have the same issues.
>

I'll see if I can get my head around that. I use recursive decoders to 
decode JSON into recursive types, but the values I output from this are not 
recursive. I did not realize it is possible to build a recursive value with 
decoders? Do you have an example?

These are mutually recursive types from a content model that I have been 
working with. If the server sends me some content with a list of 
relationships, and one of the relationships refers to the original content, 
I will end up with multiple copies of the original content in the structure 
decoded into Elm. 

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.

type Content =
    Content
    {
    slug : Maybe String
    , path : Maybe String
    , contentType : Maybe (ContentType)
    , model : ContentModel
    , relationships : Maybe (List Relationship)
    , container : Maybe (List Content)
    , id : Maybe String
    }


type Relationship =
    Relationship
    {
    subject : Maybe (Content)
    , predicate : Maybe PredicateType
    , object : Maybe (Content)
    , id : Maybe String
    }




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