L06HindleyMilnerPrint

L06HindleyMilnerPrint - 1 http://www.csg.lcs.mit.edu/6.827...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 http://www.csg.lcs.mit.edu/6.827 L6- 1 Arvind Laboratory for Computer Science M.I.T. The Hindley-Milner Type System September 25, 2002 September 25, 2002 http://www.csg.lcs.mit.edu/6.827 L6-2 Arvind Outline General issues Type instances Type Unification Type Generalization A form al type system 2 September 25, 2002 http://www.csg.lcs.mit.edu/6.827 L6-3 Arvind What are Types? A m ethod of classifying objects (values) in a language x :: ? says object x has type ?? or object x belongs to a type ? denotes a set of values. This notion of types is different from languages like C, where a type is a storage class specifier. September 25, 2002 http://www.csg.lcs.mit.edu/6.827 L6-4 Arvind Type Correctness If x :: , then only those operations that are appropriate to set m ay be perform ed on x. A program is type correct if it never perform s a wrong operation on an object.- Add an In t and a Bool- Head of an In t- Square root of a list 3 September 25, 2002 http://www.csg.lcs.mit.edu/6.827 L6-5 Arvind Type Safety A language is type safe if only type correct program s can be w ritten in that language. Most languages are not type safe, i.e., have holes in their type system s. Fortran: Equivalence, Parameter passing Pascal: Variant records, files C , C + + : Pointers, type casting However, Java, CLU, Ada, M L, Id, Haskell, pH etc. are type safe. September 25, 2002 http://www.csg.lcs.mit.edu/6.827 L6-6 Arvind Type Declaration vs Reconstruction Languages where the user must declare the types CLU, Pascal, Ada, C, C++, Fortran, Java Languages where type declarations are not needed and the types are reconstructed at run tim e Scheme, Lisp Languages where type declarations are generally not needed but allowed, and types are reconstructed at com pile tim e ML, Id, Haskell, pH A language is said to be statically typed if type-checking is done at com pile tim e 4 September 25, 2002 http://www.csg.lcs.mit.edu/6.827 L6-7 Arvind Polymorphism In a monomorphic language like Pascal, one defines a different length function for each type of list In a polym orphic language like ML, one defines a polym orphic type (list t), w here t...
View Full Document

This note was uploaded on 02/13/2012 for the course CS 91.531 taught by Professor Giam during the Fall '09 term at UMass Lowell.

Page1 / 11

L06HindleyMilnerPrint - 1 http://www.csg.lcs.mit.edu/6.827...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online