From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 5200EBCAF for ; Sun, 3 Jul 2005 13:42:22 +0200 (CEST) Received: from [192.168.0.3] (planar.net0.nerim.net [213.41.168.102]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j63BgLZD007662 for ; Sun, 3 Jul 2005 13:42:21 +0200 Mime-Version: 1.0 (Apple Message framework v622) In-Reply-To: References: <42C4228D.3080000@ps.uni-sb.de> <000d01c57dab$21871e30$14b2a8c0@wiko> Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: Content-Transfer-Encoding: 7bit From: Damien Doligez Subject: Re: [Caml-list] bizarre type Date: Sun, 3 Jul 2005 13:42:20 +0200 To: caml-list X-Mailer: Apple Mail (2.622) X-j-chkmail-Score: MSGID : 42C7CF1D.000 on nez-perce : j-chkmail score : X : 0/20 1 X-Miltered: at nez-perce with ID 42C7CF1D.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; damien:01 damien:01 caml-list:01 val:01 foo:01 bool:01 abbreviation:01 val:01 foo:01 2005,:98 wrote:01 doligez:01 doligez:01 marshal:01 marshal:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: On Jun 30, 2005, at 23:42, Julien Verlaguet wrote: > In fact it prevents me from writting this : > > type 'a marshalled=string > > let make (x : 'a)=(Marshal.to_string x [] : 'a marshalled);; > > And then do all type of operations in a type safe way on strings. If I understand correctly, this is your problem: Objective Caml version 3.08.3+4 (2005-06-21) # type 'a marshalled=string;; type 'a marshalled = string # let make (x : 'a)=(Marshal.to_string x [] : 'a marshalled);; val make : 'a -> 'a marshalled = # make 1 = make "foo";; (* int marshalled is the same as string marshalled *) - : bool = false It works better you use a concrete type instead of an abbreviation: # type 'a marsh2 = Marsh of string;; type 'a marsh2 = Marsh of string # let make2 (x : 'a) = (Marsh (Marshal.to_string x []) : 'a marsh2);; val make2 : 'a -> 'a marsh2 = # make2 1 = make2 "foo";; (* int marsh2 is not the same as string marsh2 *) ^^^^^^^^^^^ This expression has type string marsh2 but is here used with type int marsh2 # -- Damien