Download presentation
Presentation is loading. Please wait.
Published byAniya Hopp Modified over 9 years ago
1
CSE-321 Programming Languages Predicative Polymorphic -Calculus POSTECH May 23, 2007 박성우
2
2 System F
3
3 Identity Function
4
4 Pairing Function
5
5 Typing Rules
6
6 Reduction Rules for System F
7
7 Outline System F V Type reconstruction Predicative polymorphic -calculus Let-polymorphism Value restriction
8
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
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)
10
Arguably, type annotations do not always improve code readability.
11
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
12 Type Reconstruction in System F type reconstruction type erasure typable
13
13 Erasure Function
14
14 Type Reconstruction and Erasure type reconstruction type erasure typable
15
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
16 Outline System F V Type reconstruction V Predicative polymorphic -calculus Let-polymorphism Value restriction
17
17 Predicative Polymorphic -Calculus Sublanguage of System F –decidable type reconstruction –supports polymorphism Helps us to understand let-polymorphism.
18
18 Types in System F
19
19 Types in P.P. -Calculus
20
20 Predicative Polymorphic -Calculus A variable is assigned a monotype. A type application uses a monotype.
21
21 Typing Rules
22
Polymorphic types in predicative polymorphic -calculus are USELESS!
23
23 Let's apply id to two different types bool and int.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.