state monad
backtracking unification