Rewrite ForeignTy as non-tail-recursive to simplify proving equality