From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.8 required=5.0 tests=AWL,DNS_FROM_RFC_POST, SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id B8536BB84 for ; Wed, 28 Jan 2009 21:57:16 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AugBAKdVgElC+Vq1kWdsb2JhbACTTz8BAQEBCQsKBxEDqQKBBY4UAQMBA4VEBg X-IronPort-AV: E=Sophos;i="4.37,339,1231110000"; d="scan'208";a="22165145" Received: from ik-out-1112.google.com ([66.249.90.181]) by mail3-smtp-sop.national.inria.fr with ESMTP; 28 Jan 2009 21:57:16 +0100 Received: by ik-out-1112.google.com with SMTP id b32so2041132ika.1 for ; Wed, 28 Jan 2009 12:57:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:content-type:cc:subject:from :to:references:in-reply-to:date:message-id:user-agent; bh=RXQaps6640b02lEB3IGWgu2ZvkE6RGC56kdfOpCe0KQ=; b=RzW2udT58/BWOhsjv4QEXfytRMgX+CURYKGtqky/8x3pYUpTT31m+uoUa3oKAYXDxR hKitfXJy0y/CY735k/b5/DXFIcj1UB9kTNb3iXnmXEERaUsBB251LQiy/9pUdit7IOW1 tZqZ9Yx4JAOhcvhP9HU8h0R/nhaHW3STbExF4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=content-type:cc:subject:from:to:references:in-reply-to:date :message-id:user-agent; b=RyK6XS23T1FaCj5VodoKMbqCXz5c/ynEzBvNObEvRSo5HJM/JYqWwZcoFackS8Szut t7jRBgqZK8/y+79sfzZlbUModBx4gxzwI0mX23DMfplgmMiyCgM8Zn1w39O0m5ORSzPj 3nm4vlLs73z6qkjs+I0jzcjlFU9i6s9Xrxexc= Received: by 10.102.247.4 with SMTP id u4mr2069879muh.128.1233176235627; Wed, 28 Jan 2009 12:57:15 -0800 (PST) Received: from localhost (home.feydakins.org [82.229.164.236]) by mx.google.com with ESMTPS id t10sm3635674muh.1.2009.01.28.12.57.14 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 28 Jan 2009 12:57:14 -0800 (PST) Content-Type: text/plain; charset=UTF-8 Cc: Matthieu Wipliez , caml-list Subject: Re: Re : [Caml-list] Warning wished From: Nicolas Pouillard To: Julien SIGNOLES References: <1233150828.7199.213.camel@localhost> <739317.49579.qm@web27001.mail.ukl.yahoo.com> <1233152654.7199.227.camel@localhost> In-Reply-To: <1233152654.7199.227.camel@localhost> Date: Wed, 28 Jan 2009 21:56:10 +0100 Message-Id: <1233175897-sup-9607@ausone.local> User-Agent: Sup/git X-Spam: no; 0.00; matthieu:01 bug:01 compiler:01 unify:01 existential:01 sig:01 val:01 struct:01 2009:98 2009:98 polymorphic:01 polymorphic:01 emit:01 caml-list:01 caml:02 Excerpts from Julien SIGNOLES's message of Wed Jan 28 15:24:14 +0100 2009: > Le mercredi 28 janvier 2009 à 14:07 +0000, Matthieu Wipliez a écrit : > > > Hello, > > > > > > Is it a bug or a well-known feature that the above program does not emit > > > a warning (because "f x" should have type unit in the body of "g") ? > > > > > > ===== > > > let f x = x > > > let g x = f x; 1 > > > (* let _ = g 2 *) > > > ==== > > > > I'm not familiar with the internals of the compiler, but what I suppose is happening is that it tries to unify the type of "f x" and "unit", and this succeeds because "f x" has type 'a, which can be unified with anything. The meaning of "a;b" seems to be let _ = a in b rather than let () = a in b. > > > > But like I said, these are suppositions. > > Sure. However in my real case, I had an "ok" code like this : > > let f x : 'a -> unit = ... > let g x = > f x; > x > > I changed a little bit the specification of f : > > let f x : 'a -> 'a = ... > > I just expected that caml helps me to find all the instances where I had > to take care of this specification change. Such a thing is one of the > very good features of caml. Unfortunatly, in this case, caml did not > help me while the old implementation of "g" became wrong with the new > specification of "f" :-(. That's because (let f x : 'a -> 'a = ...) is not a specification for a polymorphic function, this is rather an existential quantification than a universal one. They are some ugly tricks to ensure a polymorphic function, like this one: module M : sig val f : t -> 'a -> 'a end = struct let f x = ... end include M Best regards, -- Nicolas Pouillard