CSE 130 Lecture Notes - Lecture 7: Type Inference, Type Safety, Compile Time
Document Summary
Ex: apply :: (a -> b) -> a -> b: fix a function, has to return of type a", has to return of type b". Way of static analysis - checking before programs executed. Ex: insert :: k -> set k -> set k. Probably adds an element to a set, and returns a new set (since its immutable! ) Eg: reading a file readfile :: filepath -> io string. Expects a file path , a well-formatted string (/__/__*) Returns a string and also does io. Ex: obj. prop1 (prop1 is always some offset of the object in memory) Segfault (not always, if other arrays next to arr) ( runtime/hardware (os) ) Answer: depends on the language! undefined/throw exception ( runtime ) (compile time! (statically): compile-time, runtime, runtime/hardware. Return x < 10 ? x : x(); More advanced type systems can type this function. @ runtime: dynamic type checking only checks types for the path that is executing.