From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id E5BD3BB81 for ; Thu, 11 Nov 2004 09:56:17 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id iAB8uHI3025182 for ; Thu, 11 Nov 2004 09:56:17 +0100 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id JAA02958 for ; Thu, 11 Nov 2004 09:56:16 +0100 (MET) Received: from smtp3.adl2.internode.on.net (smtp3.adl2.internode.on.net [203.16.214.203]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id iAB8uEhs015323 for ; Thu, 11 Nov 2004 09:56:15 +0100 Received: from [192.168.1.200] (ppp195-248.lns1.syd2.internode.on.net [203.122.195.248]) by smtp3.adl2.internode.on.net (8.12.9/8.12.9) with ESMTP id iAB8uAOU045433; Thu, 11 Nov 2004 19:26:10 +1030 (CST) Subject: Re: [Caml-list] module type... From: skaller Reply-To: skaller@users.sourceforge.net To: Pietro Abate Cc: ocaml ml In-Reply-To: <20041111083547.GA13116@pulp.anu.edu.au> References: <20041111083547.GA13116@pulp.anu.edu.au> Content-Type: text/plain Message-Id: <1100163369.2579.70.camel@pelican.wigram> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 11 Nov 2004 19:56:10 +1100 Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 41932931.002 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 4193292E.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 sourceforge:01 wrote:01 sig:01 struct:01 compiler:01 coerced:01 'int':01 val:01 glebe:01 ...:98 ...:98 061:98 abstract:01 expression:01 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.0 X-Spam-Level: On Thu, 2004-11-11 at 19:35, Pietro Abate wrote: > Hi all, > I've a problem that boils down to this code below. > module type ElType = > sig > type t > end > ;; > module TermType : ElType = > struct > type t = int > end > ;; > let l : TermType.t list = [1;2];; > > (* -------------- *) > > now the compiler tells me that: > > This expression has type int but is here used with type TermType.t > > but TermType.t should be unified with int... > By coercing TermType to ElType, you have coerced 'int' to 't', where 't' is an abstract type, in other words the coercion is hiding the representation. There are two ways around this (a) don't hide the representation, put type t = int into the module type ElType as well. (b) add a type constructor function to the module TermType let term_of_int i = i with declaration in ElType: val term_of_int: int -> t -- John Skaller, mailto:skaller@users.sf.net voice: 061-2-9660-0850, snail: PO BOX 401 Glebe NSW 2037 Australia Checkout the Felix programming language http://felix.sf.net