English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Type issue
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-11-23 (04:01)
From: Jonathan T Bryant <jtbryant@v...>
Subject: Type issue

I don't understand the following typing:

# type 'a t = Cond of bool t * 'a t * 'a t | Value of 'a;;
type 'a t = Cond of bool t * 'a t * 'a t | Value of 'a

# let rec f t = match t with
      Cond (c,t,e) -> if f c then f t else f e
    | Value x -> x
val f : bool t -> bool = <fun>

I don't understand why f isn't of type 'a t -> 'a.  I understand that f 
is applied to a bool t, but I would think that that would just be a 
particular instantiation of 'a, not enough to fully determine its type.

--Jonathan Bryant