From db4fd450e7750a0e585a0cdae15ffd904cac41ec Mon Sep 17 00:00:00 2001 From: Phil Freeman Date: Sun, 24 Aug 2014 17:15:51 -0700 Subject: [PATCH] Fix #569 --- examples/passing/OperatorAssociativity.purs | 15 +++++++++++++++ src/Language/PureScript/Pretty/JS.hs | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 examples/passing/OperatorAssociativity.purs 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'