COMP 302 Lecture Notes - Lecture 20: Church Encoding, Object-Oriented Programming, Universal Quantification
Document Summary
Remember there was a typing rule that was like: Assume : f has type 1 -> 2 , and arg has type 1 . Rule : apply f to arg and you get result 2 . What we really want to say is something more like: Rule : if there is a unifier for 1 and 3 , then we can apply f to arg. This is what tells you that you don"t have to exactly match the types for the arguments, but it has to be just general enough to accommodate the argument type. That"s the flexibility you get from a polymorphic type system. The engine that allows you to tell whether an application"s type is correct is unification. The same symbol for different pieces of code. You just have different things and you decide to give them the same name. The typical example is +, which is used for integer arithmetic and floating point arithmetic.