git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Fix 1166, Use bind instead of >>= in do desugaring
commit764ba6e27788e72091db01e944781b2b6731d3ff authorPhil Freeman <paf31@cantab.net> dateMon 15 Jun 2015, 19:00 (11 years ago) parentbfb4c0e
3 files changed+8−5
src/Language/PureScript/CodeGen/JS/Optimizer/MagicDo.hs+2−2 src/Language/PureScript/Constants.hs+3 src/Language/PureScript/Sugar/DoNotation.hs+3−3
src/Language/PureScript/CodeGen/JS/Optimizer/MagicDo.hs+2−2
@@ -81,8 +81,8 @@ magicDo' = everywhereOnJS undo . everywhereOnJSTopDown convert
8181 isPure (JSApp purePoly [effDict]) | isPurePoly purePoly && isEffDict C.applicativeEffDictionary effDict = True
8282 isPure _ = False
8383 -- Check if an expression represents the polymorphic >>= function
84− isBindPoly (JSAccessor prop (JSVar prelude)) = prelude == C.prelude && prop == identToJs (Op (C.>>=))
85− isBindPoly (JSIndexer (JSStringLiteral bind) (JSVar prelude)) = prelude == C.prelude && bind == (C.>>=)
84+ isBindPoly (JSAccessor prop (JSVar prelude)) = prelude == C.prelude && (prop `elem` map identToJs [Ident C.bind, Op (C.>>=)])
85+ isBindPoly (JSIndexer (JSStringLiteral bind) (JSVar prelude)) = prelude == C.prelude && (bind `elem` [C.bind, (C.>>=)])
8686 isBindPoly _ = False
8787 -- Check if an expression represents the polymorphic return function
8888 isRetPoly (JSAccessor returnEscaped (JSVar prelude)) = prelude == C.prelude && returnEscaped == C.returnEscaped
src/Language/PureScript/Constants.hs+3
@@ -71,6 +71,9 @@ module Language.PureScript.Constants where
7171(||) :: String
7272(||) = "||"
7373
74+bind :: String
75+bind = "bind"
76+
7477unsafeIndex :: String
7578unsafeIndex = "unsafeIndex"
7679
src/Language/PureScript/Sugar/DoNotation.hs+3−3
@@ -10,7 +10,7 @@
1010--
1111-- |
1212-- This module implements the desugaring pass which replaces do-notation statements with
13−-- appropriate calls to (>>=) from the Prelude.Monad type class.
13+-- appropriate calls to bind from the Prelude.Monad type class.
1414--
1515-----------------------------------------------------------------------------
1616
@@ -32,7 +32,7 @@ import Control.Monad.Error.Class (MonadError(..))
3232import Control.Monad.Supply.Class
3333
3434-- |
35−-- Replace all @DoNotationBind@ and @DoNotationValue@ constructors with applications of the Prelude.(>>=) function,
35+-- Replace all @DoNotationBind@ and @DoNotationValue@ constructors with applications of the Prelude.bind function,
3636-- and all @DoNotationLet@ constructors with let expressions.
3737--
3838desugarDoModule :: forall m. (Applicative m, MonadSupply m, MonadError MultipleErrors m) => Module -> m Module
@@ -45,7 +45,7 @@ desugarDo d =
4545 in f d
4646 where
4747 bind :: Expr
48− bind = Var (Qualified Nothing (Op (C.>>=)))
48+ bind = Var (Qualified Nothing (Ident (C.bind)))
4949
5050 replace :: Expr -> m Expr
5151 replace (Do els) = go els