git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Make operator precedence in the Prelude match Haskell #176
6fd0295Phil Freeman
examples/passing/Eff.purs+1−1
@@ -24,4 +24,4 @@ import TestEff
24main = do
24main = do
25 n <- test1
25 n <- test1
26 Trace.print n
26 Trace.print n
27− --Trace.print test2
27+ Trace.print test2
libraries/prelude/prelude.purs+19−19
@@ -12,8 +12,8 @@ module Prelude where
12 konst :: forall a b. a -> b -> a
12 konst :: forall a b. a -> b -> a
13 konst a _ = a
13 konst a _ = a
14
14
15− infixr 5 >>>
15+ infixr 9 >>>
16− infixr 5 <<<
16+ infixr 9 <<<
17
17
18 class Category a where
18 class Category a where
19 id :: forall t. a t t
19 id :: forall t. a t t
@@ -25,8 +25,8 @@ module Prelude where
25 (<<<) f g x = f (g x)
25 (<<<) f g x = f (g x)
26 (>>>) f g x = g (f x)
26 (>>>) f g x = g (f x)
27
27
28− infixr 1000 $
28+ infixr 0 $
29− infixl 1000 #
29+ infixl 0 #
30
30
31 ($) :: forall a b. (a -> b) -> a -> b
31 ($) :: forall a b. (a -> b) -> a -> b
32 ($) f x = f x
32 ($) f x = f x
@@ -92,12 +92,12 @@ module Prelude where
92 a' <- a
92 a' <- a
93 ret (f' a')
93 ret (f' a')
94
94
95− infixl 5 *
95+ infixl 7 *
96− infixl 5 /
96+ infixl 7 /
97− infixl 5 %
97+ infixl 7 %
98
98
99− infixl 7 -
99+ infixl 6 -
100− infixl 7 +
100+ infixl 6 +
101
101
102 class Num a where
102 class Num a where
103 (+) :: a -> a -> a
103 (+) :: a -> a -> a
@@ -149,8 +149,8 @@ module Prelude where
149 (%) = numMod
149 (%) = numMod
150 negate = numNegate
150 negate = numNegate
151
151
152− infixl 9 ==
152+ infixl 4 ==
153− infixl 9 /=
153+ infixl 4 /=
154
154
155 class Eq a where
155 class Eq a where
156 (==) :: a -> a -> Boolean
156 (==) :: a -> a -> Boolean
@@ -205,10 +205,10 @@ module Prelude where
205 (==) _ _ = false
205 (==) _ _ = false
206 (/=) xs ys = not (xs == ys)
206 (/=) xs ys = not (xs == ys)
207
207
208− infixl 3 <
208+ infixl 4 <
209− infixl 3 >
209+ infixl 4 >
210− infixl 3 <=
210+ infixl 4 <=
211− infixl 3 >=
211+ infixl 4 >=
212
212
213 class Ord a where
213 class Ord a where
214 (<) :: a -> a -> Boolean
214 (<) :: a -> a -> Boolean
@@ -308,7 +308,7 @@ module Prelude where
308 zshr = numZshr
308 zshr = numZshr
309 complement = numComplement
309 complement = numComplement
310
310
311− infixl 4 !!
311+ infixl 8 !!
312
312
313 foreign import (!!) "function $bang$bang(xs) {\
313 foreign import (!!) "function $bang$bang(xs) {\
314 \ return function(n) {\
314 \ return function(n) {\
@@ -316,8 +316,8 @@ module Prelude where
316 \ };\
316 \ };\
317 \}" :: forall a. [a] -> Number -> a
317 \}" :: forall a. [a] -> Number -> a
318
318
319− infixr 11 ||
319+ infixr 2 ||
320− infixr 11 &&
320+ infixr 3 &&
321
321
322 class BoolLike b where
322 class BoolLike b where
323 (&&) :: b -> b -> b
323 (&&) :: b -> b -> b
@@ -345,7 +345,7 @@ module Prelude where
345 (||) = boolOr
345 (||) = boolOr
346 not = boolNot
346 not = boolNot
347
347
348− infixr 6 ++
348+ infixr 5 ++
349
349
350 foreign import (++) "function $plus$plus(s1) {\
350 foreign import (++) "function $plus$plus(s1) {\
351 \ return function(s2) {\
351 \ return function(s2) {\
src/Language/PureScript/Sugar/Operators.hs+1−1
@@ -60,7 +60,7 @@ customOperatorTable fixities =
60 let
60 let
61 applyUserOp name t1 t2 = App (App (Var name) t1) t2
61 applyUserOp name t1 t2 = App (App (Var name) t1) t2
62 userOps = map (\(name, Fixity a p) -> (name, applyUserOp name, p, a)) . M.toList $ fixities
62 userOps = map (\(name, Fixity a p) -> (name, applyUserOp name, p, a)) . M.toList $ fixities
63− sorted = sortBy (compare `on` (\(_, _, p, _) -> p)) userOps
63+ sorted = reverse $ sortBy (compare `on` (\(_, _, p, _) -> p)) userOps
64 groups = groupBy ((==) `on` (\(_, _, p, _) -> p)) sorted
64 groups = groupBy ((==) `on` (\(_, _, p, _) -> p)) sorted
65 in
65 in
66 map (map (\(name, f, _, a) -> (name, f, a))) groups
66 map (map (\(name, f, _, a) -> (name, f, a))) groups