@@ -115,11 +115,6 @@ inlineCommonValues = everywhereOnCpp convert
115115 | isDict boundedBoolean dict && isFn fnTop fn = CppBooleanLiteral True
116116 convert (CppApp (CppApp fn [dict]) [x])
117117 | isDict ringInt dict && isFn fnNegate fn = CppUnary Negate x
118− convert (CppApp fn [dict, x, y])
119− | isDict semiringInt dict && isFn fnAdd fn = CppBinary Add x y
120− | isDict semiringInt dict && isFn fnMultiply fn = CppBinary Multiply x y
121− | isDict euclideanRingInt dict && isFn fnDivide fn = CppBinary Divide x y
122− | isDict ringInt dict && isFn fnSubtract fn = CppBinary Subtract x y
123118 convert (CppApp (CppApp (CppApp fn [dict]) [x]) [y])
124119 | isDict semiringInt dict && isFn fnAdd fn = CppBinary Add x y
125120 | isDict semiringInt dict && isFn fnMultiply fn = CppBinary Multiply x y
@@ -140,7 +135,6 @@ inlineNonClassFunction :: (Text, Text) -> (Cpp -> Cpp -> Cpp) -> Cpp -> Cpp
140135inlineNonClassFunction (m, op) f = everywhereOnCpp convert
141136 where
142137 convert :: Cpp -> Cpp
143− convert (CppApp op' [x, y]) | isOp op' = f x y
144138 convert (CppApp (CppApp op' [x]) [y]) | isOp op' = f x y
145139 convert other = other
146140 isOp (CppAccessor (CppVar longForm) (CppVar m')) =
@@ -225,21 +219,18 @@ inlineCommonOperators = applyAll $
225219 binary dict fns op = everywhereOnCpp convert
226220 where
227221 convert :: Cpp -> Cpp
228− convert (CppApp fn [dict', x, y]) | isDict dict dict' && isFn fns fn = CppBinary op x y
229222 convert (CppApp (CppApp (CppApp fn [dict']) [x]) [y]) | isDict dict dict' && isFn fns fn = CppBinary op x y
230223 convert other = other
231224 binary' :: Text -> Text -> BinaryOperator -> Cpp -> Cpp
232225 binary' moduleName opString op = everywhereOnCpp convert
233226 where
234227 convert :: Cpp -> Cpp
235− convert (CppApp fn [x, y]) | isFn (moduleName, opString) fn = CppBinary op x y
236228 convert (CppApp (CppApp fn [x]) [y]) | isFn (moduleName, opString) fn = CppBinary op x y
237229 convert other = other
238230 unary :: (Text, Text) -> (Text, Text) -> UnaryOperator -> Cpp -> Cpp
239231 unary dicts fns op = everywhereOnCpp convert
240232 where
241233 convert :: Cpp -> Cpp
242− convert (CppApp fn [dict', x]) | isDict dicts dict' && isFn fns fn = CppUnary op x
243234 convert (CppApp (CppApp fn [dict']) [x]) | isDict dicts dict' && isFn fns fn = CppUnary op x
244235 convert other = other
245236 unary' :: Text -> Text -> UnaryOperator -> Cpp -> Cpp
@@ -289,19 +280,9 @@ inlineCommonOperators = applyAll $
289280inlineFnComposition :: forall m. MonadSupply m => Cpp -> m Cpp
290281inlineFnComposition = everywhereOnCppTopDownM convert where
291282 convert :: Cpp -> m Cpp
292− convert (CppApp fn [dict', x, y, z])
293− | isFnCompose dict' fn = return $ CppApp x [CppApp y [z]]
294− | isFnComposeFlipped dict' fn = return $ CppApp y [CppApp x [z]]
295− convert (CppApp (CppApp (CppApp (CppApp fn [dict']) [x]) [y]) [z])
283+ convert (CppApp (CppApp (CppApp (CppApp fn [dict']) [x]) [y]) [z])
296284 | isFnCompose dict' fn = return $ CppApp x [CppApp y [z]]
297285 | isFnComposeFlipped dict' fn = return $ CppApp y [CppApp x [z]]
298− convert (CppApp fn [dict', x, y])
299− | isFnCompose dict' fn = do
300− arg <- freshName
301− return $ CppLambda [CaptureAll] [(arg, constAnyRef)] Nothing (CppBlock [CppReturn $ CppApp x [CppApp y [CppVar arg]]])
302− | isFnComposeFlipped dict' fn = do
303− arg <- freshName
304− return $ CppLambda [CaptureAll] [(arg, constAnyRef)] Nothing (CppBlock [CppReturn $ CppApp y [CppApp x [CppVar arg]]])
305286 convert (CppApp (CppApp (CppApp fn [dict']) [x]) [y])
306287 | isFnCompose dict' fn = do
307288 arg <- freshName