@@ -666,6 +666,17 @@ inlineFunctions js =
666666 | otherwise = 0
667667
668668
669+reduceContinuations :: JS -> JS
670+reduceContinuations = transformJS reduceHelper
671+ where
672+ reduceHelper :: JS -> JS
673+ reduceHelper (JSNew "__IDRRT__Cont" [JSFunction [] (
674+ JSReturn js@(JSNew "__IDRRT__Cont" [JSFunction [] body])
675+ )]) = js
676+
677+ reduceHelper js = transformJS reduceHelper js
678+
679+
669680reduceConstant :: JS -> JS
670681reduceConstant
671682 (JSApp (JSIdent "__IDRRT__tailcall") [JSFunction [] (
@@ -853,6 +864,7 @@ codegenJavaScript target definitions filename outputType = do
853864 , map (optimizeEvalTailcalls ("__IDR__mAPPLY0", "__IDRRT__APPLYTC"))
854865 , map removeInstanceChecks
855866 , inlineFunctions
867+ , map reduceContinuations
856868 ]
857869
858870