ML type inference in presence of type classes