Rewrite error handling in the compiler with a new Result monad.