@@ -92,14 +92,20 @@ inlineValues = everywhereOnJS convert
9292 | isDict boundedBoolean dict && isFn fnTop fn = JSBooleanLiteral True
9393 convert (JSApp fn [value]) | isFn fromNumber fn = JSBinary BitwiseOr value (JSNumericLiteral (Left 0 ))
9494 convert (JSApp (JSApp (JSApp fn [dict]) [x]) [y])
95+ | isDict semiringInt dict && isFn fnAdd fn = JSBinary BitwiseOr (JSBinary Add x y) (JSNumericLiteral (Left 0 ))
96+ | isDict semiringInt dict && isFn fnMultiply fn = JSBinary BitwiseOr (JSBinary Multiply x y) (JSNumericLiteral (Left 0 ))
9597 | isDict moduloSemiringInt dict && isFn fnDivide fn = JSBinary BitwiseOr (JSBinary Divide x y) (JSNumericLiteral (Left 0 ))
98+ | isDict ringInt dict && isFn fnSubtract fn = JSBinary BitwiseOr (JSBinary Subtract x y) (JSNumericLiteral (Left 0 ))
9699 convert other = other
97100 fnZero = (C. prelude, C. zero)
98101 fnOne = (C. prelude, C. one)
99102 fnBottom = (C. prelude, C. bottom)
100103 fnTop = (C. prelude, C. top)
101104 fromNumber = (C. dataInt, C. fromNumber)
105+ fnAdd = (C. prelude, (C. +) )
102106 fnDivide = (C. prelude, (C. /) )
107+ fnMultiply = (C. prelude, (C. *) )
108+ fnSubtract = (C. prelude, (C. -) )
103109
104110inlineOperator :: (String , String ) -> (JS -> JS -> JS ) -> JS -> JS
105111inlineOperator (m, op) f = everywhereOnJS convert
@@ -115,15 +121,14 @@ inlineCommonOperators :: JS -> JS
115121inlineCommonOperators = applyAll $
116122 [ binary semiringNumber (C. +) Add
117123 , binary semiringNumber (C. *) Multiply
118- , binary semiringInt (C. +) Add
119- , binary semiringInt (C. *) Multiply
120124
121125 , binary ringNumber (C. -) Subtract
122126 , unary ringNumber C. negate Negate
123127 , binary ringInt (C. -) Subtract
124128 , unary ringInt C. negate Negate
125129
126130 , binary moduloSemiringNumber (C. /) Divide
131+ , binary moduloSemiringInt C. mod Modulus
127132
128133 , binary eqNumber (C. ==) EqualTo
129134 , binary eqNumber (C. /=) NotEqualTo
0 commit comments