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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 242647F9BB for ; Tue, 1 Jul 2014 17:27:12 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of jdimino@janestreet.com) identity=pra; client-ip=38.105.200.229; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="jdimino@janestreet.com"; x-sender="jdimino@janestreet.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of jdimino@janestreet.com designates 38.105.200.229 as permitted sender) identity=mailfrom; client-ip=38.105.200.229; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="jdimino@janestreet.com"; x-sender="jdimino@janestreet.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mxout3.mail.janestreet.com) identity=helo; client-ip=38.105.200.229; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="jdimino@janestreet.com"; x-sender="postmaster@mxout3.mail.janestreet.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlQBAJ3SslMmacjlnGdsb2JhbABag19agm6oSAaRLIkZAYEFCBYPAQEBAQEGFgk8hAMBAQEDARIRHQEBNwEECwsEBzcCAiISAQUBHAYTGweIGAgDAqBEaoowd4UCAQWXFREGCoVliTAHgneBTJpqkhIYKYRz X-IPAS-Result: AlQBAJ3SslMmacjlnGdsb2JhbABag19agm6oSAaRLIkZAYEFCBYPAQEBAQEGFgk8hAMBAQEDARIRHQEBNwEECwsEBzcCAiISAQUBHAYTGweIGAgDAqBEaoowd4UCAQWXFREGCoVliTAHgneBTJpqkhIYKYRz X-IronPort-AV: E=Sophos;i="5.01,582,1400018400"; d="scan'208";a="83159458" Received: from mxout3.mail.janestreet.com ([38.105.200.229]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 01 Jul 2014 17:27:11 +0200 Received: from tot-oib-smtp1 ([172.27.22.15] helo=tot-smtp) by mxout3.mail.janestreet.com with esmtps (UNKNOWN:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.82) (envelope-from ) id 1X1zxd-0002WZ-Nl for caml-list@inria.fr; Tue, 01 Jul 2014 11:27:09 -0400 Received: from tot-dmz-mxgoog1.delacy.com ([172.27.224.14] helo=mxgoog2.janestreet.com) by tot-smtp with esmtps (TLSv1:AES256-SHA:256) (Exim 4.72) (envelope-from ) id 1X1zxd-0003Vx-L9 for caml-list@inria.fr; Tue, 01 Jul 2014 11:27:09 -0400 Received: from mail-ig0-f182.google.com ([209.85.213.182]) by mxgoog2.janestreet.com with esmtp (Exim 4.76) (envelope-from ) id 1X1zxd-0000MU-Iv for caml-list@inria.fr; Tue, 01 Jul 2014 11:27:09 -0400 Received: by mail-ig0-f182.google.com with SMTP id l13so5561124iga.9 for ; Tue, 01 Jul 2014 08:27:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=google; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=SW+kFyAGyHQqFh5cLEPzNRkbcUIdnN6oFpqMBee/KPY=; b=XiMvke+k1XBBjo6fuz1fYI6gVc2t8VTlIxPTpKUvH+9cg+ceyfLk+KBsLokRpdpE8r CnQ1KgIps+3GPztUHHfN+FzdI1nmj4zOS535cF8O+PoouBW0k5PgCTxMKIT5ljjsgb+Y CAtCmLd7jlr46eNol4jwvCgB0GA8V2Hc+mWx4= 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:date :message-id:subject:from:to:cc:content-type; bh=SW+kFyAGyHQqFh5cLEPzNRkbcUIdnN6oFpqMBee/KPY=; b=eb0VR5Ye0GbA7zrQxwMsRS4I3kZChIip3nFV+kBwU3RbBK63g+hpjQKPWJJNS0Sk4w EjSN2upOj0/hRgGcqOmOn+h73UlqQCOmmHT5Tp0/strEV7nHdtQLANtMu5rOwY9f37s+ 90d4AeSVUMlzqu3G8/xKTSSzv/YEudKaDF+WMtSeR4UKiHrk9reE1ZMxLiIZiKaiWNSN CQXNQU7D8eQZHnMDztaWCrPsn3SEPQM+PvVTF867swMk8+7fu1si5QzPMoRxaf32kVv+ gjHtt6AE4PNXwrCV+w86qikyG4090F4Yp0pgnmPoGHDZzuV8nr/fy8AQ8OxBghUZh8BQ injQ== X-Gm-Message-State: ALoCoQle2ZMh+lY4ZYbnXzsEU8PiTahriCXiaUWCGUDzPjo+i2jbu0pvYQsPcTI60nkTozu8b8qhvlrrPamBcTxHBTt0blxKrU/WBT2Tc9CjN9oIZpHCAiEYXfRrJRRqiBa79fcaeDh5 X-Received: by 10.43.117.133 with SMTP id fm5mr44434733icc.3.1404228429360; Tue, 01 Jul 2014 08:27:09 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.43.117.133 with SMTP id fm5mr44434725icc.3.1404228429274; Tue, 01 Jul 2014 08:27:09 -0700 (PDT) Received: by 10.50.122.5 with HTTP; Tue, 1 Jul 2014 08:27:09 -0700 (PDT) In-Reply-To: <20140701095955.GE4120@kerneis.info> References: <20140701095955.GE4120@kerneis.info> Date: Tue, 1 Jul 2014 16:27:09 +0100 Message-ID: From: Jeremie Dimino To: Gabriel Kerneis Cc: "caml-list@inria.fr" Content-Type: multipart/alternative; boundary=bcaec517c920b621d604fd2368c3 Subject: Re: [Caml-list] Extending Format strings --bcaec517c920b621d604fd2368c3 Content-Type: text/plain; charset=UTF-8 On Tue, Jul 1, 2014 at 10:59 AM, Gabriel Kerneis wrote: > Dear all, > > in CIL , the module Pretty provides a Format-like > interface with a few extensions compared to usual format strings. > Implementation-wise, it uses string_of_format and re-implements most of > the logic of the pre-4.02 Format module, with Obj.magic all over the > place. > > I wondered if anyone has done something similar in their own project > (extending Format in one way or another), and if the new GADT-based > approach could provide a cleaner solution? > > One thing I quite like with the current code, despite its uglyness, is > its concision. I am right in assuming that switching to GADTs would > require a lot more boilerplate? > I had a quick look at [Pretty.dprintf] and I think you could use [CamlinternalFormat.make_printf] to implement it with 4.02. @-sequences are already recognized by the format parser in the compiler, but it should be compatible with [Pretty]'s syntax, you just have to interpret the constructors differently. It should actually make the code of [Pretty.dprintf] much simpler. -- Jeremie --bcaec517c920b621d604fd2368c3 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On T= ue, Jul 1, 2014 at 10:59 AM, Gabriel Kerneis <gabriel@kerneis.info= > wrote:
Dear all,

in CIL <http://cil.sf.ne= t>, the module Pretty provides a Format-like
interface with a few extensions compared to usual format strings.
Implementation-wise, it uses string_of_format and re-implements most of
the logic of the pre-4.02 Format module, with Obj.magic all over the
place.

I wondered if anyone has done something similar in their own project
(extending Format in one way or another), and if the new GADT-based
approach could provide a cleaner solution?

One thing I quite like with the current code, despite its uglyness, is
its concision. I am right in assuming that switching to GADTs would
require a lot more boilerplate?

I= had a quick look at [Pretty.dprintf] and I think you could use [Camlintern= alFormat.make_printf] to implement it with 4.02. @-sequences are already re= cognized by the format parser in the compiler, but it should be compatible = with [Pretty]'s syntax, you just have to interpret the constructors dif= ferently. It should actually make the code of [Pretty.dprintf] much simpler= .

--
Jeremie
--bcaec517c920b621d604fd2368c3--