git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
fix on (negate $ negate a)
commitf4d7c2f9bbb29418c6135f16fe028eb88ab27806 authorphilopon <philopon.dependence@gmail.com> dateWed 14 Jan 2015, 02:57 (12 years ago) parent763d0c3
3 files changed+11−5
examples/passing/Operators.purs+8 src/Language/PureScript/Pretty/JS.hs+3−3 src/Language/PureScript/Sugar/Operators.hs−2
examples/passing/Operators.purs+8
@@ -67,6 +67,12 @@ module Main where
6767 test17 :: Number
6868 test17 = negate (-1)
6969
70+ test18 :: Number
71+ test18 = negate $ negate 1
72+
73+ test19 :: Number
74+ test19 = negate $ negate (-1)
75+
7076 main = do
7177 let t1 = test1 1 2 (\x y -> x + y)
7278 let t2 = test2
@@ -85,4 +91,6 @@ module Main where
8591 let t15 = test15 1 2
8692 let t16 = test16 1 2
8793 let t17 = test17
94+ let t18 = test18
95+ let t19 = test19
8896 trace "Done"
src/Language/PureScript/Pretty/JS.hs+3−3
@@ -222,10 +222,10 @@ unary :: UnaryOperator -> String -> Operator PrinterState JS String
222222unary op str = unary' op (const str)
223223
224224negateOperator :: Operator PrinterState JS String
225−negateOperator = unary' Negate (\v -> if isNegative v then "- " else "-")
225+negateOperator = unary' Negate (\v -> if isNegate v then "- " else "-")
226226 where
227− isNegative (JSNumericLiteral num) | either (<0) (<0) num = True
228− isNegative _ = False
227+ isNegate (JSUnary Negate _) = True
228+ isNegate _ = False
229229
230230binary :: BinaryOperator -> String -> Operator PrinterState JS String
231231binary 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
5858 where
5959 (f', _, _) = everywhereOnValues id go id
6060
61− go (UnaryMinus (NumericLiteral (Left n))) = NumericLiteral (Left $ negate n)
62− go (UnaryMinus (NumericLiteral (Right n))) = NumericLiteral (Right $ negate n)
6361 go (UnaryMinus val) = App (Var (Qualified (Just (ModuleName [ProperName C.prelude])) (Ident C.negate))) val
6462 go other = other
6563