Rewrite type systems