Understanding parametric polymorphism and duck typing