on master help sign in
Make record extension more concise.
ea8ff38evancz
elm/src/Gen/CompileToJS.hs+1−3
@@ -182,9 +182,7 @@ recordToJS e cmds =
182 , ret "r" ]) ++ "()"
182 , ret "r" ]) ++ "()"
183
183
184addField (x,e) = ((++add) . assign "v") `liftM` toJS' e
184addField (x,e) = ((++add) . assign "v") `liftM` toJS' e
185− where add = concat [ "\nif ('", x, "' in r) {"
185+ where add = concat [ "\n r.", x, " = '", x, "' in r ? [v].concat(r.", x, ") : [v];" ]
186− , "\n r.", x, " = [v].concat(r.", x, ");"
187− , "\n} else { r.", x, " = [v]; }" ]
188setField (x,e) = do
186setField (x,e) = do
189 let rx = "r." ++ x
187 let rx = "r." ++ x
190 set <- globalAssign (rx ++ "[0]") `liftM` toJS' e
188 set <- globalAssign (rx ++ "[0]") `liftM` toJS' e