@@ -57,6 +57,8 @@ magicDo' = everywhereOnJS undo . everywhereOnJSTopDown convert
57 convert :: JS -> JS
57 convert :: JS -> JS
58 -- Desugar return
58 -- Desugar return
59 convert (JSApp (JSApp ret [val]) []) | isReturn ret = val
59 convert (JSApp (JSApp ret [val]) []) | isReturn ret = val
61+ convert (JSApp (JSApp pure' [val]) []) | isPure pure' = val
60 -- Desugar >>
62 -- Desugar >>
61 convert (JSApp (JSApp bind [m]) [JSFunction Nothing ["_"] (JSBlock js)]) | isBind bind && isJSReturn (last js) =
63 convert (JSApp (JSApp bind [m]) [JSFunction Nothing ["_"] (JSBlock js)]) | isBind bind && isJSReturn (last js) =
62 let JSReturn ret = last js in
64 let JSReturn ret = last js in
@@ -78,6 +80,9 @@ magicDo' = everywhereOnJS undo . everywhereOnJSTopDown convert
78 -- Check if an expression represents a monomorphic call to return for the Eff monad
80 -- Check if an expression represents a monomorphic call to return for the Eff monad
79 isReturn (JSApp retPoly [effDict]) | isRetPoly retPoly && isEffDict C.monadEffDictionary effDict = True
81 isReturn (JSApp retPoly [effDict]) | isRetPoly retPoly && isEffDict C.monadEffDictionary effDict = True
80 isReturn _ = False
82 isReturn _ = False
83+ -- Check if an expression represents a monomorphic call to pure for the Eff applicative
84+ isPure (JSApp purePoly [effDict]) | isPurePoly purePoly && isEffDict C.applicativeEffDictionary effDict = True
81 -- Check if an expression represents the polymorphic >>= function
86 -- Check if an expression represents the polymorphic >>= function
82 isBindPoly (JSAccessor prop (JSVar prelude)) = prelude == C.prelude && prop == identToJs (Op (C.>>=))
87 isBindPoly (JSAccessor prop (JSVar prelude)) = prelude == C.prelude && prop == identToJs (Op (C.>>=))
83 isBindPoly (JSIndexer (JSStringLiteral bind) (JSVar prelude)) = prelude == C.prelude && bind == (C.>>=)
88 isBindPoly (JSIndexer (JSStringLiteral bind) (JSVar prelude)) = prelude == C.prelude && bind == (C.>>=)
@@ -86,6 +91,10 @@ magicDo' = everywhereOnJS undo . everywhereOnJSTopDown convert
86 isRetPoly (JSAccessor returnEscaped (JSVar prelude)) = prelude == C.prelude && returnEscaped == C.returnEscaped
91 isRetPoly (JSAccessor returnEscaped (JSVar prelude)) = prelude == C.prelude && returnEscaped == C.returnEscaped
87 isRetPoly (JSIndexer (JSStringLiteral return') (JSVar prelude)) = prelude == C.prelude && return' == C.return
92 isRetPoly (JSIndexer (JSStringLiteral return') (JSVar prelude)) = prelude == C.prelude && return' == C.return
88 isRetPoly _ = False
93 isRetPoly _ = False
94+ -- Check if an expression represents the polymorphic pure function
95+ isPurePoly (JSAccessor pure' (JSVar prelude)) = prelude == C.prelude && pure' == C.pure'
96+ isPurePoly (JSIndexer (JSStringLiteral pure') (JSVar prelude)) = prelude == C.prelude && pure' == C.pure'
89 -- Check if an expression represents a function in the Ef module
98 -- Check if an expression represents a function in the Ef module
90 isEffFunc name (JSAccessor name' (JSVar eff)) = eff == C.eff && name == name'
99 isEffFunc name (JSAccessor name' (JSVar eff)) = eff == C.eff && name == name'
91 isEffFunc _ _ = False
100 isEffFunc _ _ = False