Return a visitor function that replaces expressions of a given type with new expressions.

def make_type_replacement_visitor(find_types, replacement_func):
    """Return a visitor function that replaces expressions of a given type with new expressions."""
    def visitor_fn(expression):
        """Return a replacement expression if the original expression is of the correct type."""
        if isinstance(expression, find_types):
            return replacement_func(expression)
        else:
            return expression

    return visitor_fn