@@ -312,7 +312,7 @@ magicDo' = everywhere (mkT undo) . everywhere' (mkT convert)
312 isRetPoly (JSIndexer (JSStringLiteral "return") (JSAccessor "Prelude" (JSVar "_ps"))) = True
312 isRetPoly (JSIndexer (JSStringLiteral "return") (JSAccessor "Prelude" (JSVar "_ps"))) = True
313 isRetPoly _ = False
313 isRetPoly _ = False
314 -- Check if an expression represents a function in the Ef module
314 -- Check if an expression represents a function in the Ef module
315− isEffFunc name (JSAccessor name' (JSAccessor "Eff" (JSVar "_ps"))) | name == name' = True
315+ isEffFunc name (JSAccessor name' (JSAccessor "Control_Monad_Eff" (JSVar "_ps"))) | name == name' = True
316 isEffFunc _ _ = False
316 isEffFunc _ _ = False
317 -- Module names
317 -- Module names
318 prelude = ModuleName [ProperName "Prelude"]
318 prelude = ModuleName [ProperName "Prelude"]
@@ -324,7 +324,7 @@ magicDo' = everywhere (mkT undo) . everywhere' (mkT convert)
324 (TypeConstructor (Qualified (Just effModule) (ProperName "Eff")))
324 (TypeConstructor (Qualified (Just effModule) (ProperName "Eff")))
325 -- Check if an expression represents the Monad Eff dictionary
325 -- Check if an expression represents the Monad Eff dictionary
326 isEffDict (JSApp (JSVar ident) [JSObjectLiteral []]) | ident == effDictName = True
326 isEffDict (JSApp (JSVar ident) [JSObjectLiteral []]) | ident == effDictName = True
327− isEffDict (JSApp (JSAccessor prop (JSAccessor "Eff" (JSVar "_ps"))) [JSObjectLiteral []]) | prop == effDictName = True
327+ isEffDict (JSApp (JSAccessor prop (JSAccessor "Control_Monad_Eff" (JSVar "_ps"))) [JSObjectLiteral []]) | prop == effDictName = True
328 isEffDict _ = False
328 isEffDict _ = False
329 -- Remove __do function applications which remain after desugaring
329 -- Remove __do function applications which remain after desugaring
330 undo :: JS -> JS
330 undo :: JS -> JS
@@ -345,7 +345,7 @@ inlineST = everywhere (mkT convertBlock)
345 usages = findAllSTUsagesIn arg
345 usages = findAllSTUsagesIn arg
346 allUsagesAreLocalVars = all (\u -> let v = toVar u in isJust v && fromJust v `elem` refs) usages
346 allUsagesAreLocalVars = all (\u -> let v = toVar u in isJust v && fromJust v `elem` refs) usages
347 localVarsDoNotEscape = all (\r -> length (r `appearingIn` arg) == length (filter (\u -> let v = toVar u in v == Just r) usages)) refs
347 localVarsDoNotEscape = all (\r -> length (r `appearingIn` arg) == length (filter (\u -> let v = toVar u in v == Just r) usages)) refs
348− in everywhere (mkT $ convert allUsagesAreLocalVars) arg
348+ in everywhere (mkT $ convert (allUsagesAreLocalVars && localVarsDoNotEscape)) arg
349 convertBlock other = other
349 convertBlock other = other
350 -- Convert a block in a safe way, preserving object wrappers of references,
350 -- Convert a block in a safe way, preserving object wrappers of references,
351 -- or in a more aggressive way, turning wrappers into local variables depending on the
351 -- or in a more aggressive way, turning wrappers into local variables depending on the
@@ -364,7 +364,7 @@ inlineST = everywhere (mkT convertBlock)
364 JSAssignment (JSIndexer i arr) val
364 JSAssignment (JSIndexer i arr) val
365 convert _ other = other
365 convert _ other = other
366 -- Check if an expression represents a function in the ST module
366 -- Check if an expression represents a function in the ST module
367− isSTFunc name (JSAccessor name' (JSAccessor "ST" (JSVar "_ps"))) | name == name' = True
367+ isSTFunc name (JSAccessor name' (JSAccessor "Control_Monad_ST" (JSVar "_ps"))) | name == name' = True
368 isSTFunc _ _ = False
368 isSTFunc _ _ = False
369 -- Find all ST Refs initialized in this block
369 -- Find all ST Refs initialized in this block
370 findSTRefsIn = everything (++) (mkQ [] isSTRef)
370 findSTRefsIn = everything (++) (mkQ [] isSTRef)