Make matching functional.

No more side-effecting @input.