# CSE-321 Programming Languages Predicative Polymorphic -Calculus POSTECH May 23, 2007 박성우.

## Presentation on theme: "CSE-321 Programming Languages Predicative Polymorphic -Calculus POSTECH May 23, 2007 박성우."— Presentation transcript:

CSE-321 Programming Languages Predicative Polymorphic -Calculus POSTECH May 23, 2007 박성우

2 System F

3 Identity Function

4 Pairing Function

5 Typing Rules

6 Reduction Rules for System F

7 Outline System F V Type reconstruction Predicative polymorphic -calculus Let-polymorphism Value restriction

8 Which is the most readable? fn x => fn y => x + y fn x : int => fn y : int => x + y fn x : int => fn y : int => (x + y) : int

9 Which is the most readable? fn f => fn g => g o f fn f => fn g => (fn x => g (f x)) fn f : 'a -> 'b => fn g : 'b -> 'c => (fn x : 'a -> g (f x)) fn f : 'a -> 'b => fn g : 'b -> 'c => ((fn x : 'a -> (g (f x)) : 'c) : 'a -> 'c)

Arguably, type annotations do not always improve code readability.

11 Type Reconstruction Source code fn x => fn y => x + y After type reconstruction fn x : int => fn y : int => x + y : int -> int -> int

12 Type Reconstruction in System F type reconstruction type erasure typable

13 Erasure Function

14 Type Reconstruction and Erasure type reconstruction type erasure typable

15 Bad News Not every untyped expression is typable! –e.g. because every expression in System F eventually reduces to a value. Really bad news: –Type reconstruction is undecidable! –There is no algorithm for type reconstruction in System F!

16 Outline System F V Type reconstruction V Predicative polymorphic -calculus Let-polymorphism Value restriction

17 Predicative Polymorphic -Calculus Sublanguage of System F –decidable type reconstruction –supports polymorphism Helps us to understand let-polymorphism.

18 Types in System F

19 Types in P.P. -Calculus

20 Predicative Polymorphic -Calculus A variable is assigned a monotype. A type application uses a monotype.

21 Typing Rules

Polymorphic types in predicative polymorphic -calculus are USELESS!

23 Let's apply id to two different types bool and int.

Download ppt "CSE-321 Programming Languages Predicative Polymorphic -Calculus POSTECH May 23, 2007 박성우."

Similar presentations