All the material for this topic is contained in the Polymorphism and Higher Order Data chapter of Software Foundations.