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 173307FE44 for ; Sat, 9 Jul 2016 09:26:49 +0200 (CEST) IronPort-PHdr: 9a23:mXSGTxdr/WNWgshD/4EfacXzlGMj4u6mDksu8pMizoh2WeGdxc+7Zx7h7PlgxGXEQZ/co6odzbGH6+a7AydZu83JmUtBWaQEbwUCh8QSkl5oK+++Imq/EsTXaTcnFt9JTl5v8iLzG0FUHMHjew+a+SXqvnYsExnyfTB4Ov7yUtaLyZ/mj6bpodaKOV4ArQH+SIs6FA+xowTVu5teqqpZAYF19CH0pGBVcf9d32JiKAHbtR/94sCt4MwrqHwI6LoJvvRNWqTifqk+UacQTHF/azh0t/vQqALbQACTynwZW2QQ2loUUkmWpC39C7j4uDH7u+414yKaMNf7V/hgVj2o9aZmTFnzgycKLTMj2G7Sg810yqlcpUTyiQZ4xtv2Z4ecKPp3eOvlZ9QGV2dHXcEZAy5GBIqgb4IJSfIbOvpKoo/+oHMBqBK/AU+nA+a5mWwAvWP/waBvi7dpKgrBxgF1Wo9XvQ== Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=jonathan.protzenko@gmail.com; spf=Pass smtp.mailfrom=jonathan.protzenko@gmail.com; spf=None smtp.helo=postmaster@mail-pa0-f44.google.com Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of jonathan.protzenko@gmail.com) identity=pra; client-ip=209.85.220.44; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="jonathan.protzenko@gmail.com"; x-sender="jonathan.protzenko@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of jonathan.protzenko@gmail.com designates 209.85.220.44 as permitted sender) identity=mailfrom; client-ip=209.85.220.44; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="jonathan.protzenko@gmail.com"; x-sender="jonathan.protzenko@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-pa0-f44.google.com) identity=helo; client-ip=209.85.220.44; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="jonathan.protzenko@gmail.com"; x-sender="postmaster@mail-pa0-f44.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0B5AACmpoBXhizcVdFcFoN+KkMPp2aFfYYzhQSBeiKFdgKBIjgUAQEBAQEBAQERAQEBCAsLCSEvgjIEARKCEwEBBAESEQQZARsSCwEDAQsGBQsFCA0aAwICIxEBBQEKAREGDQYCAQEOEIdzAQMPCA6hDYExPjGLO4FqgloFhU8KGScDClKDSQEBAQEBAQEBAQEBAQEBAQEBAQEWAgYQhAyCC4F4glWEboJUgloFhlQMiBqEYoU8gVqEMohFgjiHBw6FX45PMIEPDw+CPxELgWxOiTIBAQE X-IPAS-Result: A0B5AACmpoBXhizcVdFcFoN+KkMPp2aFfYYzhQSBeiKFdgKBIjgUAQEBAQEBAQERAQEBCAsLCSEvgjIEARKCEwEBBAESEQQZARsSCwEDAQsGBQsFCA0aAwICIxEBBQEKAREGDQYCAQEOEIdzAQMPCA6hDYExPjGLO4FqgloFhU8KGScDClKDSQEBAQEBAQEBAQEBAQEBAQEBAQEWAgYQhAyCC4F4glWEboJUgloFhlQMiBqEYoU8gVqEMohFgjiHBw6FX45PMIEPDw+CPxELgWxOiTIBAQE X-IronPort-AV: E=Sophos;i="5.28,334,1464645600"; d="scan'208,217";a="184348564" Received: from mail-pa0-f44.google.com ([209.85.220.44]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 09 Jul 2016 09:26:45 +0200 Received: by mail-pa0-f44.google.com with SMTP id fi15so5901333pac.1 for ; Sat, 09 Jul 2016 00:26:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:message-id:date:user-agent :mime-version:in-reply-to; bh=wg13kcbdqyEZVkmW30mmD8/Wc1UsCH/0e62oq/ch3dg=; b=MYejwspU6WVpsPq3b63UvxQxAFYHhVqTvIKKeegAFzo491rmJ8p0gUV3oOX9CIBXp8 cu8Ji9uTP/no5FeN77Rp6ksLn2RLQ94jUhA/PqgmDozDjcVIpfFGyk0rMLjRVPQiQ9vp xQJswk77tu+ZEkeBGQQiJ79oEKDgvZMDYFTkqP+5ekkiEBv4m6n5Fmpb4BacOcUTnTEn dDgQNua6y+AeNvn5YGDjUWc++pIBIy8v2a/fa/odKUrqW5ThqeEiepU9UWXa1OFMiUAA ImDV4bcDogr0eUDWUqZwi2PDuBRwiGXdHz9/V6J7tFlgIvq1U5GAVQgopwRqStzsduPj 93GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:references:message-id:date :user-agent:mime-version:in-reply-to; bh=wg13kcbdqyEZVkmW30mmD8/Wc1UsCH/0e62oq/ch3dg=; b=cw3ZzxgO14z6iaI0xHODbHfmSN1uK4BQeq9fGK+p40WNyAh69W/pZ5//2pFCGJY17I zsrfxkURPj/QA4UxS9Pk70SNIhTANB2LbVAor7Yzhxwtx5M0tK/KqTynIH30XikRWpkB 3fUDC0hCE9nch68f/ejcEIBa3iYhbnIS3g15VhGRTdLjpGRywnN+ZejHcYJJr9BoLVnX U+WWEqJn0tP/Tx12WDxhJxXlEm1hNh/XJNEF/3WonFdEY5GPvgU0FSJ24tq/LPjMkHrP xlPUHDL+xdlMV2Jagv6kiEfRwcL1m0uFd6Y2GFWFq9YirIpfAZe7wET+zOzcZV3nGqmj NLvw== X-Gm-Message-State: ALyK8tJUNEGehqesdiVZzChJGVXM3/Shf4+2zeS3H1C4Ys81vO0k8nTgx/RoJBmWiC2jbQ== X-Received: by 10.66.66.108 with SMTP id e12mr16348089pat.95.1468049203696; Sat, 09 Jul 2016 00:26:43 -0700 (PDT) Received: from [192.168.1.53] ([162.222.170.100]) by smtp.gmail.com with ESMTPSA id v126sm1784398pfb.60.2016.07.09.00.26.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 09 Jul 2016 00:26:43 -0700 (PDT) From: Jonathan Protzenko To: Gabriel Scherer Cc: Nicolas Ojeda Bar , OCaml Mailing List , Rodolphe Lepigre References: <20160708080134.GK11971@HPArchRod.localdomain> <20160708081627.GL11971@HPArchRod.localdomain> Message-ID: <48a9be2f-3ba9-099b-c65e-548028e012aa@gmail.com> Date: Sat, 9 Jul 2016 00:26:22 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:49.0) Gecko/20100101 Thunderbird/49.0a2 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------8C930BEF7CD5396C6226C4C9" Subject: Re: [Caml-list] Printf.sprintf "%a" This is a multi-part message in MIME format. --------------8C930BEF7CD5396C6226C4C9 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Basically what we did for Mezzo. All printers are intended to work with Buffer.t and %a; then, define a bunch of variants of fprintf, iprintf, kprintf, sprintf, eprintf that work with Buffer.t https://github.com/protz/mezzo/blob/master/lib/MzString.ml On 7/8/16 3:53 AM, Gabriel Scherer wrote: > For non-formatted printing, I find that bprintf (using Buffer.t) is > the more composable primitive. > > On Fri, Jul 8, 2016 at 4:16 AM, Rodolphe Lepigre > > wrote: > > Thanks for your answer! > > > I don't think this is possible with Printf. But if you can > switch to Format > > you can use Format.asprintf instead. > > Yes, I know it is possible to use Format. This is actually what I > am doing > currently! However, I am not using any of the formating features, > so I'd > like to switch to Printf to avoid going from channels to > formatters all the > time... > > >> Dear list, > >> > >> If I define two values > >> > >> val p : type out_channel -> blop -> unit > >> val e : blop > >> > >> then I can do something like > >> > >> Printf.printf "%a" p e > >> > >> but I can't find a way to do something like > >> > >> Printf.sprintf "%a" p e > >> > >> which is not well-typed. Is there any trick that I can use to avoid > >> changing the type of [p] to [blop -> string]? > >> > >> Cheers, > >> > >> Rodolphe > > Cheers, > > Rodolphe > -- > Rodolphe Lepigre > LAMA, Université Savoie Mont Blanc, FRANCE > http://lama.univ-smb.fr/~lepigre/ > > On 08/07/2016 10:08, Nicolas Ojeda Bar wrote: > > -- > 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 > > --------------8C930BEF7CD5396C6226C4C9 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit Basically what we did for Mezzo. All printers are intended to work with Buffer.t and %a; then, define a bunch of variants of fprintf, iprintf, kprintf, sprintf, eprintf that work with Buffer.t

https://github.com/protz/mezzo/blob/master/lib/MzString.ml

On 7/8/16 3:53 AM, Gabriel Scherer wrote:
For non-formatted printing, I find that bprintf (using Buffer.t) is the more composable primitive.

On Fri, Jul 8, 2016 at 4:16 AM, Rodolphe Lepigre <rodolphe.lepigre@univ-savoie.fr> wrote:
Thanks for your answer!

> I don't think this is possible with Printf.  But if you can switch to Format
> you can use Format.asprintf instead.

Yes, I know it is possible to use Format. This is actually what I am doing
currently! However, I am not using any of the formating features, so I'd
like to switch to Printf to avoid going from channels to formatters all the
time...

>> Dear list,
>>
>> If I define two values
>>
>>   val p : type out_channel -> blop -> unit
>>   val e : blop
>>
>> then I can do something like
>>
>>   Printf.printf "%a" p e
>>
>> but I can't find a way to do something like
>>
>>   Printf.sprintf "%a" p e
>>
>> which is not well-typed. Is there any trick that I can use to avoid
>> changing the type of [p] to [blop -> string]?
>>
>> Cheers,
>>
>> Rodolphe

Cheers,

Rodolphe
--
Rodolphe Lepigre
LAMA, Université Savoie Mont Blanc, FRANCE
http://lama.univ-smb.fr/~lepigre/
On 08/07/2016 10:08, Nicolas Ojeda Bar wrote:

--
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


--------------8C930BEF7CD5396C6226C4C9--