def chain(*rules):
    """Compose a sequence of rules so that they apply to the expr sequentially."""
    def chain_rl(expr):
        for rule in rules:
            expr = rule(expr)
        return expr
    return chain_rl