Algorithm W (proposed by Milner) for type inference