Rewrite `expr` as a single dispatch function.