@@ -54,19 +54,11 @@ magicDo' = everywhereOnCpp undo . everywhereOnCppTopDown convert
5454 -- Desugar monomorphic calls to >>= and return for the Eff monad
5555 convert :: Cpp -> Cpp
5656 -- Desugar pure & return
57− convert (CppApp (CppApp pure' [dict, val]) []) | isPure (CppApp pure' [dict]) = val
5857 convert (CppApp (CppApp pure' [val]) []) | isPure pure' = val
5958 -- Desugar >>
60− convert (CppApp bind [dict, m, CppLambda _ [] rty (CppBlock cpp)]) | isBind (CppApp bind [dict]) =
61− CppFunction fnName [] rty [] $ CppBlock (CppApp m [] : map applyReturns cpp )
6259 convert (CppApp (CppApp bind [m]) [CppLambda _ [] rty (CppBlock cpp)]) | isBind bind =
6360 CppFunction fnName [] rty [] $ CppBlock (CppApp m [] : map applyReturns cpp )
6461 -- Desugar >>=
65− convert (CppApp bind [dict, m, CppLambda _ [arg] rty (CppBlock cpp)]) | isBind (CppApp bind [dict]) =
66− CppFunction fnName [] rty [] $ CppBlock (app' : map applyReturns cpp)
67− where
68− app' | fst arg == C.__unused = CppApp m []
69− | otherwise = CppVariableIntroduction arg [] (Just (CppApp m []))
7062 convert (CppApp (CppApp bind [m]) [CppLambda _ [arg] rty (CppBlock cpp)]) | isBind bind =
7163 CppFunction fnName [] rty [] $ CppBlock (app' : map applyReturns cpp)
7264 where
@@ -74,12 +66,12 @@ magicDo' = everywhereOnCpp undo . everywhereOnCppTopDown convert
7466 | otherwise = CppVariableIntroduction arg [] (Just (CppApp m []))
7567 -- Desugar untilE
7668 convert (CppApp (CppApp f [arg]) []) | isEffFunc C.untilE f =
77− CppApp (CppLambda [CaptureAll] [] Nothing (CppBlock [ CppWhile (CppUnary Not (CppApp arg [])) (CppBlock []), CppReturn $ CppMapLiteral Record []])) []
69+ CppApp (CppLambda [CaptureAll] [] Nothing (CppBlock [ CppWhile (CppUnary Not (CppApp arg [])) (CppBlock []), CppReturn $ CppVar "nullptr"])) []
7870 -- Desugar whileE
7971 convert (CppApp (CppApp f [arg1, arg2]) []) | isEffFunc C.whileE f =
80− CppApp (CppLambda [CaptureAll] [] Nothing (CppBlock [ CppWhile (CppApp arg1 []) (CppBlock [ CppApp arg2 [] ]), CppReturn $ CppMapLiteral Record []])) []
72+ CppApp (CppLambda [CaptureAll] [] Nothing (CppBlock [ CppWhile (CppApp arg1 []) (CppBlock [ CppApp arg2 [] ]), CppReturn $ CppVar "nullptr"])) []
8173 convert (CppApp (CppApp (CppApp f [arg1]) [arg2]) []) | isEffFunc C.whileE f =
82− CppApp (CppLambda [CaptureAll] [] Nothing (CppBlock [ CppWhile (CppApp arg1 []) (CppBlock [ CppApp arg2 [] ]), CppReturn $ CppMapLiteral Record []])) []
74+ CppApp (CppLambda [CaptureAll] [] Nothing (CppBlock [ CppWhile (CppApp arg1 []) (CppBlock [ CppApp arg2 [] ]), CppReturn $ CppVar "nullptr"])) []
8375 convert other = other
8476 -- Check if an expression represents a monomorphic call to >>= for the Eff monad
8577 isBind (CppApp fn [dict]) | isDict (C.eff, C.bindEffDictionary) dict && isBindPoly fn = True