diff --git a/examples/passing/OperatorAssociativity.purs b/examples/passing/OperatorAssociativity.purs new file mode 100644 index 0000000000..e0036c5d47 --- /dev/null +++ b/examples/passing/OperatorAssociativity.purs @@ -0,0 +1,15 @@ +module Main where + +import Control.Monad.Eff + +bug :: Number -> Number -> Number +bug a b = 0 - (a - b) + +foreign import explode + "function explode() {\ + \ throw new Error('Assertion failed!');\ + \}":: forall eff a. Eff eff a + +main = case bug 0 2 of + 2 -> Debug.Trace.trace "Done!" + _ -> explode diff --git a/src/Language/PureScript/Pretty/JS.hs b/src/Language/PureScript/Pretty/JS.hs index 7933302a14..fc4ea0b601 100644 --- a/src/Language/PureScript/Pretty/JS.hs +++ b/src/Language/PureScript/Pretty/JS.hs @@ -190,7 +190,7 @@ unary op str = Wrap match (++) match' _ = Nothing binary :: BinaryOperator -> String -> Operator PrinterState JS String -binary op str = AssocR match (\v1 v2 -> v1 ++ " " ++ str ++ " " ++ v2) +binary op str = AssocL match (\v1 v2 -> v1 ++ " " ++ str ++ " " ++ v2) where match :: Pattern PrinterState JS (JS, JS) match = mkPattern match'