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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 8C21C7F72A for ; Fri, 12 Aug 2016 14:51:50 +0200 (CEST) IronPort-PHdr: 9a23:IGuqXx38Pi5I9cBXsmDT+DRfVm0co7zxezQtwd8ZsekWLPad9pjvdHbS+e9qxAeQG96KsrQd06GL7+igATVGusfZ9ihaMdRlbFwssY0uhQsuAcqIWwXQDcXBSGgEJvlET0Jv5HqhMEJYS47UblzWpWCuv3ZJQk2sfTR8Kum9IIPOlcP/j7n0oMyKJVwQz2fhKfMqdVPt/F2X7pFXyaJZaY8JgiPTpXVJf+kEjUhJHnm02yjG28Gr4ZR4+D5Rsf9yv+RJUKH9YrhqBecAVGduGykP6cbqrRjOSxeUrjtZCz1O00kAPw+Qpir9U5jtqCzi8qJY2SKaNMDyB/hgXDWp765mTFnzjyoIKyQ+6EnWjNB9iORQpxf39DJlxIuBQ4iWPfZjNvfedNATSXcHXs9fXipIBIqUYI4GDu5HNuFd+dqu72ASpAezUFH/TNjkzSVF0zqvhfU3 Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=kakadu.hafanana@gmail.com; spf=Pass smtp.mailfrom=kakadu.hafanana@gmail.com; spf=None smtp.helo=postmaster@mail-ua0-f179.google.com Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of kakadu.hafanana@gmail.com) identity=pra; client-ip=209.85.217.179; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="kakadu.hafanana@gmail.com"; x-sender="kakadu.hafanana@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of kakadu.hafanana@gmail.com designates 209.85.217.179 as permitted sender) identity=mailfrom; client-ip=209.85.217.179; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="kakadu.hafanana@gmail.com"; x-sender="kakadu.hafanana@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-ua0-f179.google.com) identity=helo; client-ip=209.85.217.179; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="kakadu.hafanana@gmail.com"; x-sender="postmaster@mail-ua0-f179.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0BaAAAYxq1Xf7PZVdFehBt8B61di0eBfRyGAQKBQAc4FAEBAQEBAQEBEQEBCQsLCRcxgjIEARMBghQBBRIRHQEIEx0BAwwGBQsNAgImAgIiAREBBQEcBhMih3QBAxehFIEyPjKLPIFqglsFhk0KGScNVINsAQEBAQYBAQEBGwIGEHGJdoRAgwGCWgWPCooygiyMaYM1jA6MNYI4Ex6BDx6EMzkyhysBAQE X-IPAS-Result: A0BaAAAYxq1Xf7PZVdFehBt8B61di0eBfRyGAQKBQAc4FAEBAQEBAQEBEQEBCQsLCRcxgjIEARMBghQBBRIRHQEIEx0BAwwGBQsNAgImAgIiAREBBQEcBhMih3QBAxehFIEyPjKLPIFqglsFhk0KGScNVINsAQEBAQYBAQEBGwIGEHGJdoRAgwGCWgWPCooygiyMaYM1jA6MNYI4Ex6BDx6EMzkyhysBAQE X-IronPort-AV: E=Sophos;i="5.28,510,1464645600"; d="scan'208";a="187514964" Received: from mail-ua0-f179.google.com ([209.85.217.179]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 12 Aug 2016 14:51:49 +0200 Received: by mail-ua0-f179.google.com with SMTP id k90so40166595uak.1 for ; Fri, 12 Aug 2016 05:51:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=+Cf189cuWBPdb2g22gyQraBBDpNf8kNiKcaj3wYSdVs=; b=cMMvgrmFStfKqJ4ChtM0f5x7132w/+tbKe2MqPCm5aHSNgR0PGhLtHogSp0bg5w02J B5eVZJTtNV955c+YFFRSPKDHNClk5+p67JvqgymRdWI3CXPQKA9ucH43jaEe7qYHrvEL uWhlnutrkLdeCjdcLG77WBZPVGfo1+IWwTUZvQljqV1vRuT3cS78N5k/VhnOdq2j7C+4 bWMJm+mUxZOvVL3V3lUKSRoaBXHd4tWwT/APqfZ7q2uKpCM18MMSKVHUtnw/y665mKM0 n259rpYXxvqshJK+3/lk0tDgdcx/z3yMKLa098qzqkqYcpyc7au7+Qs1NDFBpJ9PtnPl vwnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=+Cf189cuWBPdb2g22gyQraBBDpNf8kNiKcaj3wYSdVs=; b=m9nG5oQlBPIFdhkrMMgrF+0VaJmsELC1ER9rTUL01gd9oHKIcFGDfbT1M+lFJzF1IC dOe7Y/5azPvuuRQy0RMOGPCKAAsH7kLhR4xJG9Zg1W/0F+YlW3IrRB0CfDsoW8wIQXiU tceMk16rBW3DncE3GPPKFBn4M92hoRs4cSrdtIu6zv+EqNlA7L0SB0CfgVG3jrBLMYX1 EZBJdJ/TcvOo0gSg9+FZIup+LYWD/y/26YmYN2UzDfdXTzOAbqcA1Xz70l8NIfePYMZL kvG/wKIrMGbdugU6Q/ojXHS9UkwghGAiCrNN80fZdft4LK7/UTw7AArVd5htZq54sANh kyWA== X-Gm-Message-State: AEkooutoREUrERnBavYlTkM7mM1WIOJKdpSW0xectXzlUP6+DBXtkJ7f9csszIBbWXAjMcRiiVy01lY6LjpTiw== X-Received: by 10.159.34.177 with SMTP id 46mr2479370uan.111.1471006307989; Fri, 12 Aug 2016 05:51:47 -0700 (PDT) MIME-Version: 1.0 Received: by 10.31.52.6 with HTTP; Fri, 12 Aug 2016 05:51:27 -0700 (PDT) In-Reply-To: <0F7D3B1B3C4B894D824F5B822E3E5A172CF39E46@IRSMSX102.ger.corp.intel.com> References: <0F7D3B1B3C4B894D824F5B822E3E5A172CF39E46@IRSMSX102.ger.corp.intel.com> From: Kakadu Date: Fri, 12 Aug 2016 15:51:27 +0300 Message-ID: To: "Soegtrop, Michael" Cc: "caml-list@inria.fr" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Caml-list] Question on Printf wrappers Micheal, Something lke this? let printfn fmt =3D kprintf (printf "%s\n") fmt Happy hacking, Kakadu On Fri, Aug 12, 2016 at 3:44 PM, Soegtrop, Michael wrote: > Dear Ocaml Users, > > > > it is quite common to have wrappers for printf to e.g. print errors or > warnings with some context. Prefixing is easy to do in OCaml (honestly it > took me a short while to figure it out): > > > > let prefixprintf (oc : out_channel) (fmt : ('a, out_channel, unit) format= ) : > 'a =3D > > Printf.fprintf oc "Prefix: "; > > Printf.fprintf oc fmt > > ;; > > > > I wonder how I would postfix something. Even converting the formatted out= put > first to a string and then output it together with the postfix doesn=E2= =80=99t seem > to be easy, because the formatting function must be the last call in the > function, since it has to produce the returned function. Is there some way > to make a variadic lambda expression or some other magic to handle such > cases? A similar question would be how I can print the same formatted str= ing > twice. > > > > I don=E2=80=99t have an application for this, I ask this out of pure OCaml > curiosity. So I am not so much interested in workarounds, more in an answ= er > to the question how I can return a function of type =E2=80=98a without mo= re or less > directly calling some variant of printf. > > > > Best regards, > > > > Michael > > > > Intel Deutschland GmbH > Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany > Tel: +49 89 99 8853-0, www.intel.de > Managing Directors: Christin Eisenschmid, Christian Lamprechter > Chairperson of the Supervisory Board: Nicole Lau > Registered Office: Munich > Commercial Register: Amtsgericht Muenchen HRB 186928