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
Polymorphic variants question
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-09-01 (20:43)
From: Jacques Carette <carette@m...>
Subject: Re: [Caml-list] Re: Polymorphic variants question
David Allsopp wrote:
> Incidentally, if I use an annotation free version
> let f x = if x = `A then (true, `B) else (false, (x : [< `A | `C] :> [> `A |
> `C]))
> then the inferred type of x is [< `A | `C > `A ] ... what does that mean?
This is a "point free" notation for what mathematicians would have written
`A <= x <= `A | `C

In other words, x is strictly bounded above and below by those 2 types.  
Translated into english, this means that the type from which x comes 
*must* contain an `A and *may* contain a `C and *must not* contain 
anything else.

For example, trying
let g x = f (snd (f x))
would not type.