git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
fix on (negate $ negate a)
f4d7c2fphilopon
examples/passing/Operators.purs+8
@@ -67,6 +67,12 @@ module Main where
67 test17 :: Number
67 test17 :: Number
68 test17 = negate (-1)
68 test17 = negate (-1)
69
69
70+ test18 :: Number
71+ test18 = negate $ negate 1
72+
73+ test19 :: Number
74+ test19 = negate $ negate (-1)
75+
70 main = do
76 main = do
71 let t1 = test1 1 2 (\x y -> x + y)
77 let t1 = test1 1 2 (\x y -> x + y)
72 let t2 = test2
78 let t2 = test2
@@ -85,4 +91,6 @@ module Main where
85 let t15 = test15 1 2
91 let t15 = test15 1 2
86 let t16 = test16 1 2
92 let t16 = test16 1 2
87 let t17 = test17
93 let t17 = test17
94+ let t18 = test18
95+ let t19 = test19
88 trace "Done"
96 trace "Done"
src/Language/PureScript/Pretty/JS.hs+3−3
@@ -222,10 +222,10 @@ unary :: UnaryOperator -> String -> Operator PrinterState JS String
222unary op str = unary' op (const str)
222unary op str = unary' op (const str)
223
223
224negateOperator :: Operator PrinterState JS String
224negateOperator :: Operator PrinterState JS String
225−negateOperator = unary' Negate (\v -> if isNegative v then "- " else "-")
225+negateOperator = unary' Negate (\v -> if isNegate v then "- " else "-")
226 where
226 where
227− isNegative (JSNumericLiteral num) | either (<0) (<0) num = True
227+ isNegate (JSUnary Negate _) = True
228− isNegative _ = False
228+ isNegate _ = False
229
229
230binary :: BinaryOperator -> String -> Operator PrinterState JS String
230binary :: BinaryOperator -> String -> Operator PrinterState JS String
231binary op str = AssocL match (\v1 v2 -> v1 ++ " " ++ str ++ " " ++ v2)
231binary op str = AssocL match (\v1 v2 -> v1 ++ " " ++ str ++ " " ++ v2)
src/Language/PureScript/Sugar/Operators.hs−2
@@ -58,8 +58,6 @@ removeSignedLiterals (Module mn ds exts) = Module mn (map f' ds) exts
58 where
58 where
59 (f', _, _) = everywhereOnValues id go id
59 (f', _, _) = everywhereOnValues id go id
60
60
61− go (UnaryMinus (NumericLiteral (Left n))) = NumericLiteral (Left $ negate n)
62− go (UnaryMinus (NumericLiteral (Right n))) = NumericLiteral (Right $ negate n)
63 go (UnaryMinus val) = App (Var (Qualified (Just (ModuleName [ProperName C.prelude])) (Ident C.negate))) val
61 go (UnaryMinus val) = App (Var (Qualified (Just (ModuleName [ProperName C.prelude])) (Ident C.negate))) val
64 go other = other
62 go other = other
65
63