From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by c5ff346549e7 (Postfix) with ESMTP id 672895D5 for ; Thu, 23 Aug 2018 09:29:37 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.53,277,1531778400"; d="scan'208";a="343475071" Received: from sympa.inria.fr ([193.51.193.213]) by mail2-relais-roc.national.inria.fr with ESMTP; 23 Aug 2018 11:29:35 +0200 Received: by sympa.inria.fr (Postfix, from userid 20132) id C02C0824C8; Thu, 23 Aug 2018 11:29:35 +0200 (CEST) Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id DA71082486 for ; Thu, 23 Aug 2018 11:29:29 +0200 (CEST) Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=octa@polychoron.fr; spf=Pass smtp.mailfrom=octa@polychoron.fr; spf=Pass smtp.helo=postmaster@quaesituri.org IronPort-PHdr: =?us-ascii?q?9a23=3AjFqurh+rOIbHOP9uRHKM819IXTAuvvDOBiVQ1KB4?= =?us-ascii?q?0+8cTK2v8tzYMVDF4r011RmVBdqds6oMotGVmpioYXYH75eFvSJKW713fDhBt/?= =?us-ascii?q?8rmRc9CtWOE0zxIa2iRSU7GMNfSA0tpCnjYgBaF8nkelLdvGC54yIMFRXjLwp1?= =?us-ascii?q?Ifn+FpLPg8it2O2+55/ebx9UiDahfLh/MAi4oQLNu8cMnIBsMLwxyhzHontJf+?= =?us-ascii?q?RZ22ZlLk+Nkhj/+8m94odt/zxftPw9+cFAV776f7kjQrxDEDsmKWE169b1uhTF?= =?us-ascii?q?UACC+2ETUmQSkhpPHgjF8BT3VYr/vyfmquZw3jSRMMvrRr42RDui9b9mRgL2hi?= =?us-ascii?q?cJNzA382/ZhcJ/g61ZvB2vqAdyw5LXbYyPKPZyYq3QcNEcSGFcXshRTStBAoak?= =?us-ascii?q?YoUPC+oBOvxYr4jnqFsIsBCzGQ+sBOzxxT9MmHD2wbE60+U8GgzB2wwvA84Ov2?= =?us-ascii?q?7PodXtM6cSVeC0w7XIzTXEdfNW3jH95JLGchA7uPyBW697f8nJyUQ3Fw7JlEic?= =?us-ascii?q?pIjkMj+P1OkBqWiW4/d4We+simMrsR99riWry8s2l4XFmoAYxkra+Sh23oo4I8?= =?us-ascii?q?CzRlRhbt6+CpRQsjmXN4toTcMmRGFloD86yqActpGlZygKyYgnxwPFa/yGaYSI?= =?us-ascii?q?5QjjVOmJLTd5gnJqZq6/ig6y/ES61+HxUsi53ExIoyZfktTAq2gB1xnJ5ciGTv?= =?us-ascii?q?t98F2h2TGK1w3L7eFLPVw0mrDAJp45xb4wkpoSvljDHi/xgkX2i6mWel8q+uiy?= =?us-ascii?q?8+jneKnppoeAN49ojQHzKrghlda6AeQ8KwQOW2mb+f+g1LD45k34QLBKjuUsna?= =?us-ascii?q?XDsZDaI94bpq+jDANP3IYj8UX3MzDz290dmTwDLUlZUBOBlYngfV/Uc97iCvLq?= =?us-ascii?q?rVCrijZiwbjvOLLsBpjRMnmLxLDqYb9V80lY2QEzyspY4dRaEOdSc7rIRkbtuY?= =?us-ascii?q?mAXVcCOAuuzrO/UYQv5sYlQWuKR5ShHubXuF6M6PgoJrDRNpcSvCf2K/8/4Pio?= =?us-ascii?q?g2VrwAZBL5ns5oMebTWDJtojO1+QOCe+mtAFAGwKuRA5Sqrkkg/aCGMBVzOJR6?= =?us-ascii?q?s5owoDJsemAIPEH97/maGI0Ty6AoBMZyZBEF/eSHo=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0BwHAA6fn5b/zMHxAVbHQEBIgEGAYM3Z?= =?us-ascii?q?QN8KINvlDNMAQEBAQEBBoEILYhehHaITYF6CxsQAYRAAgiDBBoGAQQyFgECAQE?= =?us-ascii?q?CAQEBAQFsHAyCNSKCYQEFIwQLAQUIAQE4DwsYAgImAgJXEwgBAYMeAYF0EaFnb?= =?us-ascii?q?3szgnUBAQWBbIVvCIELiBQXeYEHgTmCPS6Efk2CNIJXh28hkw4Jf4UziTUdgga?= =?us-ascii?q?GPIV+kz+BSAEwgVJNJxE7gmkJihh0hUBteQGNYAEB?= X-IPAS-Result: =?us-ascii?q?A0BwHAA6fn5b/zMHxAVbHQEBIgEGAYM3ZQN8KINvlDNMAQE?= =?us-ascii?q?BAQEBBoEILYhehHaITYF6CxsQAYRAAgiDBBoGAQQyFgECAQECAQEBAQFsHAyCN?= =?us-ascii?q?SKCYQEFIwQLAQUIAQE4DwsYAgImAgJXEwgBAYMeAYF0EaFnb3szgnUBAQWBbIV?= =?us-ascii?q?vCIELiBQXeYEHgTmCPS6Efk2CNIJXh28hkw4Jf4UziTUdggaGPIV+kz+BSAEwg?= =?us-ascii?q?VJNJxE7gmkJihh0hUBteQGNYAEB?= X-IronPort-AV: E=Sophos;i="5.53,277,1531778400"; d="scan'208";a="343474981" Received: from quaesituri.org ([5.196.7.51]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Aug 2018 11:29:01 +0200 Received: from [192.168.1.13] (AMarseille-655-1-642-242.w86-219.abo.wanadoo.fr [86.219.107.242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by quaesituri.org (Postfix) with ESMTPSA id 585A0103D98 for ; Thu, 23 Aug 2018 11:28:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mail.quaesituri.org; s=mail; t=1535016533; bh=CJ/4fCxRS6B3APJJZMCmz+7jyDnNBJsmiPlkyNgfgJQ=; h=Subject:To:References:From:Date:In-Reply-To; b=wED31RLSVzpnxbBhJMwRdo2RMWICeUDIx74UA7UZTmjU0V9Xn59wli/Bg+H25o5xb ysf6Pkj1hyUhmlzRV9JWI7NfHGdWdnRFJxyUgNK7tqNshgjEF6SZh5Vz/FJzqbg/B+ XMhMhTLCHHsWXAJO3bKg5SohIaXWA0xcBSov460s= To: caml-list@inria.fr References: <20180823091552.vq5oizsushwfivgz@annexia.org> From: Florian Angeletti Message-ID: Date: Thu, 23 Aug 2018 11:28:59 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <20180823091552.vq5oizsushwfivgz@annexia.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US-large Subject: Re: [Caml-list] Returning printf from a function Reply-To: Florian Angeletti X-Loop: caml-list@inria.fr X-Sequence: 17031 Errors-to: caml-list-owner@inria.fr Precedence: list Precedence: bulk Sender: caml-list-request@inria.fr X-no-archive: yes List-Id: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: This is the value restriction at work, you can avoid the issue by replacing let printer = get_printer true in ... where the type of printer is "Format.formatter -> ('_weak1, Format.formatter, unit) format -> '_weak1",  with let printer x = get_printer true x in ... − octachron. On 23/08/2018 11:15, Richard W.M. Jones wrote: > This is a problem we hit from time to time and I don't think I've ever > really understood why it happens. This made up example shows the > essence: > > ---------------------------------------------------------------------- > let get_printer out = > if out then Printf.printf else Printf.fprintf stderr > > let () = > let printer = get_printer true in > printer "hello\n"; > printer "goodbye %s\n" "everyone" (* line 7 *) > ---------------------------------------------------------------------- > > $ ocamlopt test2.ml > File "test2.ml", line 7, characters 2-9: > Error: This function has type (unit, out_channel, unit) format -> unit > It is applied to too many arguments; maybe you forgot a `;'. > > Type inference in line 6 seems to overspecify the inferred type of > printer, so that we get the error on line 7. > > Why? And how to fix it? > > Rich. > -- Caml-list mailing list. Subscription management and archives: https://sympa.inria.fr/sympa/arc/caml-list Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs