git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #1017 from purescript/remove-bits
bbc5cbcGary Burgess
examples/passing/OperatorAssociativity.purs−2
@@ -42,14 +42,12 @@ main = do
42 assert ((4 % 9) / 2 == 2) "(4 % 9) / 2 == 2"
42 assert ((4 % 9) / 2 == 2) "(4 % 9) / 2 == 2"
43
43
44 assert (not (1 < 0) == true) "not (1 < 0) == true"
44 assert (not (1 < 0) == true) "not (1 < 0) == true"
45− assert (not (complement (1 + 10) == 8) == true) "not (complement (1 + 10) == 8) == true"
46 assert (not ((negate 1) < 0) == false) "not ((negate 1) < 0) == false"
45 assert (not ((negate 1) < 0) == false) "not ((negate 1) < 0) == false"
47
46
48 assert (negate (1 + 10) == -11) "negate (1 + 10) == -11"
47 assert (negate (1 + 10) == -11) "negate (1 + 10) == -11"
49
48
50 assert (2 * 3 / 4 == 1.5) "2 * 3 / 4 == 1.5"
49 assert (2 * 3 / 4 == 1.5) "2 * 3 / 4 == 1.5"
51 assert (1 * 2 * 3 * 4 * 5 / 6 == 20) "1 * 2 * 3 * 4 * 5 / 6 == 20"
50 assert (1 * 2 * 3 * 4 * 5 / 6 == 20) "1 * 2 * 3 * 4 * 5 / 6 == 20"
52− assert (complement (2 / 3 * 4) == -3) "complement (2 / 3 * 4) == -3"
53
51
54 assert (1 + 10 - 5 == 6) "1 + 10 - 5 == 6"
52 assert (1 + 10 - 5 == 6) "1 + 10 - 5 == 6"
55 assert (1 + 10 * 5 == 51) "1 + 10 * 5 == 51"
53 assert (1 + 10 * 5 == 51) "1 + 10 * 5 == 51"
examples/passing/Operators.purs−4
@@ -61,9 +61,6 @@ module Main where
61 test15 :: Number -> Number -> Boolean
61 test15 :: Number -> Number -> Boolean
62 test15 a b = const false $ a `test14` b
62 test15 a b = const false $ a `test14` b
63
63
64− test16 :: Number -> Number -> Number
65− test16 x y = x .|. y .&. y
66−
67 test17 :: Number
64 test17 :: Number
68 test17 = negate (-1)
65 test17 = negate (-1)
69
66
@@ -94,7 +91,6 @@ module Main where
94 let t13 = test13 k 1 2
91 let t13 = test13 k 1 2
95 let t14 = test14 1 2
92 let t14 = test14 1 2
96 let t15 = test15 1 2
93 let t15 = test15 1 2
97− let t16 = test16 1 2
98 let t17 = test17
94 let t17 = test17
99 let t18 = test18
95 let t18 = test18
100 let t19 = test19
96 let t19 = test19
prelude/prelude.purs−85
@@ -29,7 +29,6 @@ module Prelude
29 , ComplementedLattice, not
29 , ComplementedLattice, not
30 , DistributiveLattice
30 , DistributiveLattice
31 , BooleanAlgebra
31 , BooleanAlgebra
32− , Bits, (.&.), (.|.), (.^.), shl, shr, zshr, complement
33 ) where
32 ) where
34
33
35 -- | The `Unit` type has a single inhabitant, called `unit`. It represents values with no computational content.
34 -- | The `Unit` type has a single inhabitant, called `unit`. It represents values with no computational content.
@@ -874,90 +873,6 @@ module Prelude
874 }
873 }
875 """ :: Boolean -> Boolean
874 """ :: Boolean -> Boolean
876
875
877− infixl 10 .&.
878− infixl 10 .|.
879− infixl 10 .^.
880−
881− -- | The `Bits` type class identifies types which support bitwise operations.
882− class Bits b where
883− (.&.) :: b -> b -> b
884− (.|.) :: b -> b -> b
885− (.^.) :: b -> b -> b
886− shl :: b -> Number -> b
887− shr :: b -> Number -> b
888− zshr :: b -> Number -> b
889− complement :: b -> b
890−
891− instance bitsNumber :: Bits Number where
892− (.&.) = numAnd
893− (.|.) = numOr
894− (.^.) = numXor
895− shl = numShl
896− shr = numShr
897− zshr = numZshr
898− complement = numComplement
899−
900− foreign import numAnd
901− """
902− function numAnd(n1) {
903− return function(n2) {
904− return n1 & n2;
905− };
906− }
907− """ :: Number -> Number -> Number
908−
909− foreign import numOr
910− """
911− function numOr(n1) {
912− return function(n2) {
913− return n1 | n2;
914− };
915− }
916− """ :: Number -> Number -> Number
917−
918− foreign import numXor
919− """
920− function numXor(n1) {
921− return function(n2) {
922− return n1 ^ n2;
923− };
924− }
925− """ :: Number -> Number -> Number
926−
927− foreign import numShl
928− """
929− function numShl(n1) {
930− return function(n2) {
931− return n1 << n2;
932− };
933− }
934− """ :: Number -> Number -> Number
935−
936− foreign import numShr
937− """
938− function numShr(n1) {
939− return function(n2) {
940− return n1 >> n2;
941− };
942− }
943− """ :: Number -> Number -> Number
944−
945− foreign import numZshr
946− """
947− function numZshr(n1) {
948− return function(n2) {
949− return n1 >>> n2;
950− };
951− }
952− """ :: Number -> Number -> Number
953−
954− foreign import numComplement
955− """
956− function numComplement(n) {
957− return ~n;
958− }
959− """ :: Number -> Number
960−
961module Data.Function where
876module Data.Function where
962
877
963 -- | The `on` function is used to change the domain of a binary operator.
878 -- | The `on` function is used to change the domain of a binary operator.
src/Language/PureScript/CodeGen/JS/Optimizer/Inliner.hs−8
@@ -124,14 +124,6 @@ inlineCommonOperators = applyAll $
124 , binary C.semigroupString (C.<>) Add
124 , binary C.semigroupString (C.<>) Add
125 , binary C.semigroupString (C.++) Add
125 , binary C.semigroupString (C.++) Add
126
126
127− , binaryFunction C.bitsNumber C.shl ShiftLeft
128− , binaryFunction C.bitsNumber C.shr ShiftRight
129− , binaryFunction C.bitsNumber C.zshr ZeroFillShiftRight
130− , binary C.bitsNumber (C..&.) BitwiseAnd
131− , binary C.bitsNumber (C..|.) BitwiseOr
132− , binary C.bitsNumber (C..^.) BitwiseXor
133− , unary C.bitsNumber C.complement BitwiseNot
134−
135 , binary C.latticeBoolean (C.&&) And
127 , binary C.latticeBoolean (C.&&) And
136 , binary C.latticeBoolean (C.||) Or
128 , binary C.latticeBoolean (C.||) Or
137 , binaryFunction C.latticeBoolean C.inf And
129 , binaryFunction C.latticeBoolean C.inf And
src/Language/PureScript/Constants.hs−24
@@ -65,15 +65,6 @@ module Language.PureScript.Constants where
65(/=) :: String
65(/=) :: String
66(/=) = "/="
66(/=) = "/="
67
67
68−(.&.) :: String
69−(.&.) = ".&."
70−
71−(.|.) :: String
72−(.|.) = ".|."
73−
74−(.^.) :: String
75−(.^.) = ".^."
76−
77(&&) :: String
68(&&) :: String
78(&&) = "&&"
69(&&) = "&&"
79
70
@@ -88,18 +79,6 @@ unsafeIndex = "unsafeIndex"
88negate :: String
79negate :: String
89negate = "negate"
80negate = "negate"
90
81
91−shl :: String
92−shl = "shl"
93−
94−shr :: String
95−shr = "shr"
96−
97−zshr :: String
98−zshr = "zshr"
99−
100−complement :: String
101−complement = "complement"
102−
103not :: String
82not :: String
104not = "not"
83not = "not"
105
84
@@ -205,9 +184,6 @@ eqString = "eqString"
205eqBoolean :: String
184eqBoolean :: String
206eqBoolean = "eqBoolean"
185eqBoolean = "eqBoolean"
207
186
208−bitsNumber :: String
209−bitsNumber = "bitsNumber"
210−
211boundedBoolean :: String
187boundedBoolean :: String
212boundedBoolean = "boundedBoolean"
188boundedBoolean = "boundedBoolean"
213
189