CS 342 Lecture -*- Outline -*- * type checking in Standard ML advert: important research language type checking an important topic that we've ignored so far type checking = simple program analysis note: "sml" on system is the real language standard ML information available from me on running it... ML stands for "Meta Language", as it was originally a language that was used to progrram tactics (meta-proofs) for the logic LCF (logic for computable functions) why type checking in LCF? because wanted to allow arbitrary tactics and wanted to be sure that when a proof was found it was valid, no matter how complex the tactics used to find it. ** security = no inconsistencies declaration vs. use if no declarations, at least can compare different uses... example, page 137 ** type information a simple kind of documentation e.g., how to describe find, mapcar, compose *** base types int, real, bool, string *** lists homogeneous in a typed language [1, 2, 3] : int list [1, true, "hi"] is an error types of form: T list e.g., int list, bool list, (int list) list *** tuples like records, but without names for fields not homogeneous: (1, true, "hi") : int*bool*string *** functions all take one argument, and have one result not: bool -> bool and: bool*bool -> bool *** polymorphic types type expressions that describe more specific instances include variables e.g., find can be invoked with int or bool or int list arguments find: all alpha . ((alpha->bool)*alpha list) -> bool see page 140 for other examples ** type inference systematic version of analysis you use to check type correctness e.g., both arms of an if must have same type all arguments to a function f have same type f always returns a result of same type. see 4.8.1 for more information