joeybright / json-decode-map-gen / JsonDecodeMapGen


type alias Generated =
{ call : Elm.Expression -> Elm.Expression
, callFrom : List String -> Elm.Expression -> Elm.Expression
, declaration : Dict String Elm.Declaration 
}

The generated type is returned by the generate function. If there is no built-in Json.Decode function in the elm-lang/json package, a declaration will be returned. This should be put somewhere in the generated code!

The returned declaration field is a Dict to avoid duplicate declarations when calling generate recursively. You can use Dict.union to combine different generated declarations to ensure no duplicates.

generate : List Elm.Expression -> Generated

Generate a Json.Decode.map function based on the number of expressions passed.

If there are 8 or less items in the passed list, this function will return a call to a native Json.Decode.mapX function (X being the number of passed arguments). If there are more than 8 arguments, a custom jsonDecodeMapX function will be returned along with its declaration.