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 22A187F9BB for ; Tue, 1 Jul 2014 16:16:20 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of tcui@janestreet.com) identity=pra; client-ip=38.105.200.115; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="tcui@janestreet.com"; x-sender="tcui@janestreet.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of tcui@janestreet.com designates 38.105.200.115 as permitted sender) identity=mailfrom; client-ip=38.105.200.115; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="tcui@janestreet.com"; x-sender="tcui@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@mxout1.mail.janestreet.com) identity=helo; client-ip=38.105.200.115; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="tcui@janestreet.com"; x-sender="postmaster@mxout1.mail.janestreet.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjoBAPnBslMmachznGdsb2JhbABag19agm6oSAaCZo5GiRkBgQUeDwEBAQEBBhYJPIQDAQEBAwESER0BASwLAQQLCwQHGh0CAiISAQUBChIGEwgKCQeIDAMJCAMCCKAZaoowd4UCAQWQYAOGLxEGCoVliSwEB4J3gUyEaQWVfIFIkEoYKYUO X-IPAS-Result: AjoBAPnBslMmachznGdsb2JhbABag19agm6oSAaCZo5GiRkBgQUeDwEBAQEBBhYJPIQDAQEBAwESER0BASwLAQQLCwQHGh0CAiISAQUBChIGEwgKCQeIDAMJCAMCCKAZaoowd4UCAQWQYAOGLxEGCoVliSwEB4J3gUyEaQWVfIFIkEoYKYUO X-IronPort-AV: E=Sophos;i="5.01,581,1400018400"; d="scan'208";a="83145497" Received: from mxout2.mail.janestreet.com (HELO mxout1.mail.janestreet.com) ([38.105.200.115]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 01 Jul 2014 16:16:19 +0200 Received: from tot-smtp.delacy.com ([172.27.22.15] helo=tot-smtp) by mxout1.mail.janestreet.com with esmtps (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.82) (envelope-from ) id 1X1yr3-0006zG-Ta for caml-list@inria.fr; Tue, 01 Jul 2014 10:16:17 -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 1X1yr3-0007nB-QF for caml-list@inria.fr; Tue, 01 Jul 2014 10:16:17 -0400 Received: from mail-wi0-f174.google.com ([209.85.212.174]) by mxgoog2.janestreet.com with esmtp (Exim 4.76) (envelope-from ) id 1X1yr3-0005a6-Mo for caml-list@inria.fr; Tue, 01 Jul 2014 10:16:17 -0400 Received: by mail-wi0-f174.google.com with SMTP id bs8so7935823wib.13 for ; Tue, 01 Jul 2014 07:16:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=VbxZf8EVUFNr1m4l2xIUCRIsYQHIKsLpC1yT68NERUw=; b=Y719GTec747fexOy/wgqy5/NZdZpRU6N5U5BBBI0sEFwlREcH+J+vP0RA7bSN7vD7O vzh49KJepPMVfq1CmJfx95R+vz6Y2dgGlwZNaBfln28iIx+bR3+JAFLbzkutDESvrsYR spvCGha0HXt6a3dkcP+PBlnUVW3YAaaKEiwZE= 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-type; bh=VbxZf8EVUFNr1m4l2xIUCRIsYQHIKsLpC1yT68NERUw=; b=Qwp0ryhubrxLlP1DAAA1gc5KEG16ThQmv0JxVXNJCzr0PDUooUMGRTwzw6SfSS5NJ/ cxaZJXL/5Gjh4XDQ2MiFNYJq3j2Uz/21/3hTyKrY7y635y9ZxCTWAXhHTceQkLrTRY4M rdGj52aP+x3UGby9tpgBGM85Lj8q17z6iHkj9UU9wguUUE7OfPVBovT9TSmHv5e+mc5E WK06Gjx4jFKfkJtpMJdClRMo5pIXr7HVgzxK1dfpi6sYfwegQeV9IvnPpEIbJ/pO84+V 0QlLlX/0GG6tEP7BPYOsFlAHiYZHMMmHKsYlKpuTrMLZsZon7mOZ9vS9UO/dQFZh84iW dJ+Q== X-Received: by 10.194.77.177 with SMTP id t17mr50753970wjw.55.1404224177236; Tue, 01 Jul 2014 07:16:17 -0700 (PDT) X-Gm-Message-State: ALoCoQmAC5Nb7ZIEu5Gy0mTGdiVbPNAkbRh8NN4VoD/hTTm8r6c079EdgXsXkJ5hOahpen7O1EHHVhWwzSRbJR48djaZ9hs2X2klHTPkej71MRW4g/zJwgoBXtb1NS9VviTcNv3h0a9b X-Received: by 10.194.77.177 with SMTP id t17mr50753931wjw.55.1404224176944; Tue, 01 Jul 2014 07:16:16 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.110.138 with HTTP; Tue, 1 Jul 2014 07:15:36 -0700 (PDT) In-Reply-To: <20140701095955.GE4120@kerneis.info> References: <20140701095955.GE4120@kerneis.info> From: Tianyi Cui Date: Tue, 1 Jul 2014 10:15:36 -0400 Message-ID: To: Gabriel Kerneis Cc: OCaml Mailing List Content-Type: multipart/alternative; boundary=047d7bfd0bf640929f04fd226b74 X-Sender-Copy: hkg-copy Subject: Re: [Caml-list] Extending Format strings --047d7bfd0bf640929f04fd226b74 Content-Type: text/plain; charset=UTF-8 I found https://github.com/janestreet/custom_printf quite straightforward to understand and easy to use, if most of your types already have sexp converters and to_string functions. On Tue, Jul 1, 2014 at 5: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? > > Many thanks for any example you could provide. > > With best regards, > -- > Gabriel > > -- > 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 > --047d7bfd0bf640929f04fd226b74 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I found https://github.com/janestreet/custom_printf quite straightforwar= d to understand and easy to use, if most of your types already have sexp co= nverters and to_string functions.


On Tue,= Jul 1, 2014 at 5:59 AM, Gabriel Kerneis <gabriel@kerneis.info><= /span> 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?

Many thanks for any example you could provide.

With best regards,
--
Gabriel

--
Caml-list mailing list. =C2=A0Subscription management and archives:
ht= tps://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

--047d7bfd0bf640929f04fd226b74--