1 / 11

Type Reconstruction (1)

Type Reconstruction (1). 20110248 CSE 김형준 5 월 30 일 무은재 기념관 308 호. Type Reconstruction for implicit polymorphism. Remind Γ▷ e : U Given untyped expression e can have type U ㆍ ▷ λx.x : int → int ㆍ ▷ λx.x : bool → bool ㆍ ▷ λx.x : ∀ α . α → α All these typings make sense.

maxine
Download Presentation

Type Reconstruction (1)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Type Reconstruction (1) 20110248 CSE 김형준 5월 30일 무은재 기념관 308호

  2. Type Reconstruction for implicit polymorphism Remind Γ▷e : U Given untyped expression e can have type U ㆍ ▷ λx.x : int → int ㆍ ▷ λx.x : bool → bool ㆍ ▷ λx.x : ∀α. α→α All these typings make sense.

  3. Most General Type?

  4. Untyped expressions set Types set e

  5. Untyped expressions set Types set λx.x int → int bool → bool …

  6. System Modification Bottom up Top down

  7. Gen rule • Why we need to check whether a is fresh or not? If we reuse type variable which is not fresh under gamma, there may occur unintended link between unrelated variable actually.

  8. Spec rule • Why we need Spec rule? • To instantiate polytype variable x to monotype so that we can use x polymorphically.

  9. Algorithm W • W(Γ,e) = (S,A) • type Substitution S ::= id | {A/α} | S о S • mapping from type variables to monotypes • why not polytypes? • In my opinion, we may introduce type variable when typing lambda abstraction, and the lambda binder must be monotype in let polymorphism which is base of implicit polymorphism.

  10. Question • When we talk about Most General type, by its definition, λx.x can have another most general type which is ∀β.∀α. α→α. This type also can be instantiated to all types that ∀α. α→α can be. So we need more constraint to define most general type strictly. • In my opinion, this constraint may work. This kind of unrealistic situation happens because we can create a type variables which is not used actually, so every introduced type variables must be used at least once in body. Otherwise it is not most general type because it has meaningless part(not optimization).

More Related