git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #804 from sztupi/fix-paren-expressions
e29cdb0Phil Freeman
examples/passing/OperatorAssociativity.purs+25−4
@@ -1,15 +1,36 @@
1module Main where
1module Main where
2
2
3import Control.Monad.Eff
3import Control.Monad.Eff
4+import Debug.Trace
5+
6+foreign import data Assert :: !
7+
8+foreign import assert
9+ "function assert(x) { return function (desc) {\
10+ \ return function () {\
11+ \ if (!x) throw new Error('assertion (' + desc + ') failed');\
12+ \ return {};\
13+ \ };\
14+ \};};" :: forall e. Boolean -> String -> Eff (assert :: Assert | e) Unit
4
15
5bug :: Number -> Number -> Number
16bug :: Number -> Number -> Number
6bug a b = 0 - (a - b)
17bug a b = 0 - (a - b)
7
18
8−foreign import explode
19+foreign import explode
9 "function explode() {\
20 "function explode() {\
10 \ throw new Error('Assertion failed!');\
21 \ throw new Error('Assertion failed!');\
11 \}":: forall eff a. Eff eff a
22 \}":: forall eff a. Eff eff a
12
23
13−main = case bug 0 2 of
24+main = do
14− 2 -> Debug.Trace.trace "Done!"
25+ assert (bug 0 2 == 2) "bug 0 2 == 2"
15− _ -> explode
26+ assert (0 - (0 - 2) == 2) "0 - (0 - 2) == 2"
27+ assert (0 - (0 + 2) == -2) "0 - (0 + 2) == -2"
28+
29+ assert (6 / (3 * 2) == 1) "6 / (3 * 2) == 1"
30+ assert ((6 / 3) * 2 == 4) "(6 / 3) * 2 == 4"
31+
32+ assert (6 % (2 * 2) == 2) "6 % (2 * 2) == 2"
33+ assert ((6 % 2) * 2 == 0) "(6 % 2) * 2 == 0"
34+
35+ assert (4 % (9 / 3) == 1) "4 % (9 / 3) == 1"
36+ assert ((4 % 9) / 2 == 2) "(4 % 9) / 2 == 2"
src/Language/PureScript/Pretty/JS.hs+5−5
@@ -273,11 +273,11 @@ prettyPrintJS' = A.runKleisli $ runPattern matchValue
273 , [ unary BitwiseNot "~" ]
273 , [ unary BitwiseNot "~" ]
274 , [ unary Negate "-" ]
274 , [ unary Negate "-" ]
275 , [ unary Positive "+" ]
275 , [ unary Positive "+" ]
276− , [ binary Multiply "*" ]
276+ , [ binary Multiply "*"
277− , [ binary Divide "/" ]
277+ , binary Divide "/"
278− , [ binary Modulus "%" ]
278+ , binary Modulus "%" ]
279− , [ binary Add "+" ]
279+ , [ binary Add "+"
280− , [ binary Subtract "-" ]
280+ , binary Subtract "-" ]
281 , [ binary ShiftLeft "<<" ]
281 , [ binary ShiftLeft "<<" ]
282 , [ binary ShiftRight ">>" ]
282 , [ binary ShiftRight ">>" ]
283 , [ binary ZeroFillShiftRight ">>>" ]
283 , [ binary ZeroFillShiftRight ">>>" ]