From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA11961; Wed, 3 Oct 2001 11:21:16 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA11957 for ; Wed, 3 Oct 2001 11:21:15 +0200 (MET DST) Received: from gw2-mail.cict.fr (gw2-mail.cict.fr [195.220.59.21]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f939LDr06081 for ; Wed, 3 Oct 2001 11:21:14 +0200 (MET DST) Received: from gw2-mail.cict.fr (IDENT:root@localhost.localdomain [127.0.0.1]) by gw2-mail.cict.fr (8.11.6/8.11.6) with ESMTP id f939LAk25436 for ; Wed, 3 Oct 2001 11:21:10 +0200 Received: from irit.irit.fr (irit.irit.fr [141.115.4.5]) by gw2-mail.cict.fr (8.11.6/8.11.6) with ESMTP id f939LAE25429 for ; Wed, 3 Oct 2001 11:21:10 +0200 Received: from irit.fr (erable [141.115.8.39]) by irit.irit.fr (8.9.3/8.9.3) with ESMTP id LAA20031 for ; Wed, 3 Oct 2001 11:21:16 +0200 (MET DST) Message-ID: <3BBAD886.3CCB5AC4@irit.fr> Date: Wed, 03 Oct 2001 11:21:10 +0200 From: David Chemouil Organization: IRIT X-Mailer: Mozilla 4.77 [en] (X11; U; SunOS 5.7 sun4m) X-Accept-Language: fr, fr-FR, en MIME-Version: 1.0 To: Liste Caml Subject: [Caml-list] phantom types and coercions Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hello, we have noticed a strange (at least to us) behavior of the coercion operator over phantom types. Here is an example: # type n = [`Pos];; (* non-negative number *) type n = [ `Pos] # type z = [`Neg | `Pos];; (* integer *) type z = [ `Neg | `Pos] # type (+'ph) expr = Expr of int;; (* phantom type *) type 'a expr = Expr of int # let x = ((Expr 1) : n expr);; val x : n expr = Expr 1 # (x:> z expr);; (* okay *) - : z expr = Expr 1 # let y = ((Expr 1) : z expr);; val y : z expr = Expr 1 # (y :> n expr);; (* ??? *) - : n expr = Expr 1 So, we observe the same behavior whatever the variance specification is. # type 'ph expr = Expr of int;; (* without variance *) type 'a expr = Expr of int # let x = ((Expr 1) : n expr);; val x : n expr = Expr 1 # (x:> z expr);; (* ??? *) - : z expr = Expr 1 # let y = ((Expr 1) : z expr);; val y : z expr = Expr 1 # (y :> n expr);; (* ??? *) - : n expr = Expr 1 # type (-'ph) expr = Expr of int;; (* contravariance *) type 'a expr = Expr of int # let x = ((Expr 1) : n expr);; val x : n expr = Expr 1 # (x:> z expr);; - : z expr = Expr 1 # let y = ((Expr 1) : z expr);; val y : z expr = Expr 1 # (y :> n expr);; - : n expr = Expr 1 We wonder whether it is a bug or not (anyway, this is rather counter-intuitive)...? dc -- David Chemouil [mailto:david.chemouil@irit.fr] -- -- Zeno group [http://www.irit.fr/zeno] -- Institut de recherche en informatique de Toulouse ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr