Rewrite well-typed with GADTs