SlideServe
Menu
Préférences
© SlideServe · v2026

Simple Type Inference for Structural Polymorphism

cleatus avatar
12 diapositives · 375 Views · Sep 13, 2012

Simple Type Inference for Structural Polymorphism. Jacques Garrigue Type Refinements Seminar. Motivation. HM (X) used to explain structural polymorphism Assume subtyping absent HM(X) is not a simple extension to previous algorithms Constraints occur in all types

Simple Type Inference for Structural Polymorphism - slide 1
01 / 12Simple Type Inference for Structural Polymorphism
1 / 17

Télécharger la présentation

Simple Type Inference for Structural Polymorphism
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Simple Type Inference for Structural Polymorphism Jacques Garrigue Type Refinements Seminar

  2. Motivation • HM (X) used to explain structural polymorphism • Assume subtyping absent • HM(X) is not a simple extension to previous algorithms • Constraints occur in all types • Type errors become unreadable

  3. Proposed Solution • Have “local constraints” : constraints on top of classic Hindley-Milner system • Constraints embedded in kinding context for type variables • Less powerful than HM(X)

  4. Type System • Types  ::=  | u | ! • Kind envs K ::=  | K, :: (C,9.R) • Polytypes  ::=  | 8.K . 

  5. Free Variables of Types • FVK(81,,n.K’ . ) = FVK,K’()\{1,,n} • FVK,:(C,9 .R) () = {}[ FVK(R) • FVK(u) =  • FVK(1!2) = FVK(1)[ FVK(2)

  6. Type Substitutions • K `:K’ ( is admissible between K and K’) If for all ::(C,9.R) 2 K, () is ’ • ’::(C’,9’ R’) 2 K’ • C’ ² C •  :  !’ s.t. ( R)µ R exists

  7. Typing Rules K,K0` : K Dom ()½ B K;,x:8 B.Ko. ` x:() K;,x:` e:’ K;` fun x ! e : !’ K;` e1:!’ K;` e2: K;` e1 e2 : ’

  8. Typing Rules (contd.) K;` e1 :  K;, x:` e2 :  K;` let x = e1 in e2 :  K; ` e :  B = FVK() \ FVK () K|B; ` e : 8 B.K|B. Gen

  9. Compare with HM (X) K;` e :  B = (FV () [ FV(KB) ) FV () 9 B.K;` e : 8 B.KB. KBµ K containing all kinds related to B Generalizes over tyvars not “relevant” HMX-Gen

  10. Relevant type variable • Technical definition in paper • Basically, the meaning of the type depends on what kind the variable gets • Recall, kinds include constraints • Useful to understand constraints/ type errors

  11. Benefits • Easier understanding of constraints • e.g. If  FVK(1) [ FVK(2), solving K Æ1 = 2 does not give us more information about 

  12. Conclusions • Less powerful than HM (X) : no subtyping • Gives less precise answers • More practical (??) • Sufficient for most purposes