From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by sympa.inria.fr (Postfix) with ESMTPS id 23F197ED34 for ; Tue, 3 Jul 2012 14:18:34 +0200 (CEST) Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of jean-louis.giavitto@ircam.fr) identity=pra; client-ip=129.102.3.71; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="Jean-Louis.Giavitto@ircam.fr"; x-sender="jean-louis.giavitto@ircam.fr"; x-conformance=sidf_compatible Received-SPF: Pass (mail1-smtp-roc.national.inria.fr: domain of Jean-Louis.Giavitto@ircam.fr designates 129.102.3.71 as permitted sender) identity=mailfrom; client-ip=129.102.3.71; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="Jean-Louis.Giavitto@ircam.fr"; x-sender="Jean-Louis.Giavitto@ircam.fr"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@smarthost1.ircam.fr) identity=helo; client-ip=129.102.3.71; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="Jean-Louis.Giavitto@ircam.fr"; x-sender="postmaster@smarthost1.ircam.fr"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ah8CAGLi8k+BZgNHmWdsb2JhbABFtmoiAQEBAQEICwsHFCeCRhFAPRYYAwIBAgFYCAEBFYdyAZlToXKONoMcA5U1kmQ X-IronPort-AV: E=Sophos;i="4.77,515,1336341600"; d="scan'208";a="165416194" Received: from smarthost1.ircam.fr ([129.102.3.71]) by mail1-smtp-roc.national.inria.fr with ESMTP; 03 Jul 2012 14:18:33 +0200 Received: from localhost (localhost.localdomain [127.0.0.1]) by smarthost1.ircam.fr (Postfix) with ESMTP id 6B569947F2; Tue, 3 Jul 2012 14:18:33 +0200 (CEST) X-Virus-Scanned: amavisd-new at ircam.fr Received: from smarthost1.ircam.fr ([127.0.0.1]) by localhost (smarthost1.ircam.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lVhJeiPjxRsy; Tue, 3 Jul 2012 14:18:33 +0200 (CEST) Received: from increvable.ircam.fr (increvable.ircam.fr [IPv6:2001:660:3004:2:230:48ff:fe29:4f48]) by smarthost1.ircam.fr (Postfix) with ESMTP id 3DCB4946D5; Tue, 3 Jul 2012 14:18:33 +0200 (CEST) Received: from m2055.ircam.fr (m2055.ircam.fr [129.102.64.75]) (Authenticated sender: giavitto) by increvable.ircam.fr (Postfix) with ESMTP id 30AD14E381; Tue, 3 Jul 2012 14:18:33 +0200 (CEST) Message-ID: <4FF2E319.9070004@ircam.fr> Date: Tue, 03 Jul 2012 14:18:33 +0200 From: Jean-Louis Giavitto Reply-To: jean-louis.giavitto@ircam.fr Organization: UMR STMS 9912 - IRCAM & CNRS & UPMC & Inria User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:8.0) Gecko/20111105 Thunderbird/8.0 MIME-Version: 1.0 To: caml-list@inria.fr Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Validation-by: jean-louis.giavitto@ircam.fr Subject: [Caml-list] Initialization of a polymorphic field in a record Hello. I am trying to build a record with a polymorphic field and I am unable to initialize this field. The problem can be summarized as follow. The following definitions works well: type t = { check : 'a. 'a -> bool } let return_true _ = true let make1 () = { check = return_true; } But this definition raises an error: let make2 f = { check = f; } with the message: Error: This field value has type 'a -> bool which is less general than 'b. 'b -> bool Note that let return_false _ = true let make3 c = { check = if c then return_false else return_true; } is working but that let g c = if c then return_false else return_true let make4 c = { check = g c; } raises the same error message. Making explicit the argument of make does not helps: let make5 f = { check = f; } in make5 return_true (same error message). And making explicit the type of make does not help neither: let make6 : 'a. ('a -> bool) -> t = function f -> { check = f; } (same error message). Do you have an idea how I can specify a function similar to make to buid a record of type t? In the real life, the argument f will be the result of a computation and instead of a simple signature 'a -> bool, I must deal with a signature 'a 'b. (('b) #SomeClass as 'a) * 'b -> bool Thanks for your advice, Jean-Louis Giavitto.