<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _compile_operation_rule(self, rule, left, right, result_class):
 """ Compile given operation rule, when possible for given compination of operation operands. """


        # Make sure variables always have constant with correct datatype on the
        # opposite side of operation.
        if isinstance(left, VariableRule) and isinstance(right, (ConstantRule, ListRule)):
            return self._cor_compile(
                rule,
                left,
                right,
                result_class,
                clean_variable(left.value),
                self.compilations_variable
            )
        if isinstance(right, VariableRule) and isinstance(left, (ConstantRule, ListRule)):
            return self._cor_compile(
                rule,
                right,
                left,
                result_class,
                clean_variable(right.value),
                self.compilations_variable
            )

        # Make sure functions always have constant with correct datatype on the
        # opposite side of operation.
        if isinstance(left, FunctionRule) and isinstance(right, (ConstantRule, ListRule)):
            return self._cor_compile(
                rule,
                left,
                right,
                result_class,
                left.function,
                self.compilations_function
            )
        if isinstance(right, FunctionRule) and isinstance(left, (ConstantRule, ListRule)):
            return self._cor_compile(
                rule,
                right,
                left,
                result_class,
                right.function,
                self.compilations_function
            )

        # In all other cases just keep things the way they are.
        return result_class(rule.operation, left, right)