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
Question about polymorphic variants
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-10-28 (09:56)
From: Xavier Clerc <xcforum@f...>
Subject: Question about polymorphic variants

I have a question concerning polymorphic variants and type inference.
Formulating my question from the example of section 4.2 in the ocaml  
manual (version 3.08), I define a function f:

let f = function
| `On -> 1
| `Off -> 0

which is inferred as: val f : [< `Off | `On ] -> int

Then, I use this function in the following expression :

List.map f

which is in turn inferred as: _[< `Off | `On ] list -> int list

My question is about the meaning of the leading underscore in the  
inferred type (given that I understand the meaning of the underscore  
in an expression such as "Stack.create ()" that is inferred as: '_a  


Xavier Clerc