Précédent Index Suivant



Types somme II



Syntaxe:
type .. = C1 of t1 | C2 of t2


Convention:
C of unit Þ C

#type color = Coeur | Pique | Carreau | Trefle ;;
Le type color est défini.
#type carte = Dam of color
            | Peti of int*color
            | Jok ;;
Le type carte est défini.
Coeur, Dam, Peti constructeurs de valeur.


Prise en compte de la définition
On ajoute à l'env. global Env les liaisons
ë (C1,t1 -> som), (C2,t2 -> som)<|  Env û


Règle de typage
Env  |-  Ci : ti ® som     Env  |-  e : ti
Env  |-  Ci  e : som


Précédent Index Suivant