mirror of
https://github.com/ilyakooo0/elm-bridge.git
synced 2024-09-11 14:05:55 +03:00
parent
d95b6bbb26
commit
eb08b1422a
@ -190,8 +190,8 @@ jsonSerForType' omitnull ty =
|
||||
xs ->
|
||||
let tupleArgsV = zip xs ([1..] :: [Int])
|
||||
tupleArgs =
|
||||
intercalate "," $ map (\(_, v) -> "v" ++ show v) tupleArgsV
|
||||
in "(\\(" ++ tupleArgs ++ ") -> Json.Encode.list identity [" ++ intercalate "," (map (\(t', idx) -> "(" ++ jsonSerForType t' ++ ") v" ++ show idx) tupleArgsV) ++ "])"
|
||||
intercalate "," $ map (\(_, v) -> "t" ++ show v) tupleArgsV
|
||||
in "(\\(" ++ tupleArgs ++ ") -> Json.Encode.list identity [" ++ intercalate "," (map (\(t', idx) -> "(" ++ jsonSerForType t' ++ ") t" ++ show idx) tupleArgsV) ++ "])"
|
||||
|
||||
|
||||
-- | Compile a JSON serializer for an Elm type definition
|
||||
|
@ -97,7 +97,7 @@ barSer = unlines
|
||||
, " Json.Encode.object"
|
||||
, " [ (\"name\", localEncoder_a val.name)"
|
||||
, " , (\"blablub\", Json.Encode.int val.blablub)"
|
||||
, " , (\"tuple\", (\\(v1,v2) -> Json.Encode.list identity [(Json.Encode.int) v1,(Json.Encode.string) v2]) val.tuple)"
|
||||
, " , (\"tuple\", (\\(t1,t2) -> Json.Encode.list identity [(Json.Encode.int) t1,(Json.Encode.string) t2]) val.tuple)"
|
||||
, " , (\"list\", (Json.Encode.list Json.Encode.bool) val.list)"
|
||||
, " ]"
|
||||
]
|
||||
|
@ -62,7 +62,7 @@ moduleCode elmVersion = unlines
|
||||
, " Json.Encode.object"
|
||||
, " [ (\"name\", localEncoder_a val.name)"
|
||||
, " , (\"blablub\", Json.Encode.int val.blablub)"
|
||||
, " , (\"tuple\", (\\(v1,v2) -> Json.Encode.list identity [(Json.Encode.int) v1,(Json.Encode.string) v2]) val.tuple)"
|
||||
, " , (\"tuple\", (\\(t1,t2) -> Json.Encode.list identity [(Json.Encode.int) t1,(Json.Encode.string) t2]) val.tuple)"
|
||||
, " , (\"list\", (Json.Encode.list Json.Encode.bool) val.list)"
|
||||
, " , (\"list_map\", (Json.Encode.list (encodeMap (Json.Encode.string) (Json.Encode.bool))) val.list_map)"
|
||||
, " ]"
|
||||
|
Loading…
Reference in New Issue
Block a user