rewrite type inference using Algorithm W, in order to support polymorphic-let