@@ -407,22 +407,32 @@ removeAllocations (JSSeq body) =
407removeAllocations js = transformJS removeAllocations js
407removeAllocations js = transformJS removeAllocations js
410−isJSConstant :: [String] -> JS -> Bool
410+isJSConstant :: JS -> Bool
411−isJSConstant constants js
411+isJSConstant js
412− | JSString _ <- js = True
412+ | JSString _ <- js = True
413− | JSChar _ <- js = True
413+ | JSChar _ <- js = True
414− | JSNum _ <- js = True
414+ | JSNum _ <- js = True
415− | JSType _ <- js = True
415+ | JSType _ <- js = True
416− | JSNull <- js = True
416+ | JSNull <- js = True
417+ | JSArray vals <- js = all isJSConstant vals
418 | JSApp (JSIdent "__IDRRT__bigInt") _ <- js = True
419 | JSApp (JSIdent "__IDRRT__bigInt") _ <- js = True
420− | JSArray vals <- js = all (isJSConstant constants) vals
421+ | otherwise = False
421− | JSNew "__IDRRT__Con" args <- js = all (isJSConstant constants) args
423+isJSConstantConstructor :: [String] -> JS -> Bool
424+isJSConstantConstructor constants js
427+ | JSArray vals <- js =
428+ all (isJSConstantConstructor constants) vals
429+ | JSNew "__IDRRT__Con" args <- js =
430+ all (isJSConstantConstructor constants) args
431+ | JSIndex (JSProj (JSIdent _) "vars") (JSNum _) <- js =
423 | JSIdent name <- js
433 | JSIdent name <- js
424− , name `elem` constants = True
434+ , name `elem` constants =
426 | otherwise = False
436 | otherwise = False
@@ -450,12 +460,12 @@ inlineJS (JSApp (JSProj (JSFunction args (JSReturn body)) "apply") [
450 ) (n + 1)
460 ) (n + 1)
452inlineJS (JSApp (JSIdent "__IDR__mEVAL0") [val])
462inlineJS (JSApp (JSIdent "__IDR__mEVAL0") [val])
453− | isJSConstant [] val = val
463+ | isJSConstant val = val
455inlineJS (JSApp (JSIdent "__IDRRT__tailcall") [
465inlineJS (JSApp (JSIdent "__IDRRT__tailcall") [
456 JSFunction [] (JSReturn val)
466 JSFunction [] (JSReturn val)
458− | isJSConstant [] val = val
468+ | isJSConstant val = val
460inlineJS (JSApp (JSFunction [arg] (JSReturn ret)) [val])
470inlineJS (JSApp (JSFunction [arg] (JSReturn ret)) [val])
461 | JSNew con [tag, vals] <- ret
471 | JSNew con [tag, vals] <- ret
@@ -1044,7 +1054,7 @@ extractLocalConstructors js =
1044 , all isConstant args =
1054 , all isConstant args =
1046 | otherwise =
1056 | otherwise =
1047− isJSConstant globalCons js
1057+ isJSConstantConstructor globalCons js
1049 extractLocalConstructors' js = [js]
1059 extractLocalConstructors' js = [js]
@@ -1140,7 +1150,8 @@ evalCons js =
1141 collapsable :: JS -> Bool
1151 collapsable :: JS -> Bool
1142 collapsable (JSIdent _) = True
1152 collapsable (JSIdent _) = True
1143− collapsable js = isJSConstant (map fst cons) js
1153+ collapsable js = isJSConstantConstructor (map fst cons) js
1145 match js = transformJS match js
1156 match js = transformJS match js