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 6EAAF7F7AF for ; Mon, 5 Oct 2015 15:49:11 +0200 (CEST) IronPort-PHdr: 9a23:d8QkkxI1amAxDzd1D9mcpTZWNBhigK39O0sv0rFitYgVKvvxwZ3uMQTl6Ol3ixeRBMOAu64C1bqd7f2ocFdDyKjCmUhKSIZLWR4BhJdetC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TWM5DIfUi/yKRBybrysXNWC04Lph6vsptX6WEZhunmUWftKNhK4rAHc5IE9oLBJDeIP8CbPuWZCYO9MxGlldhq5lhf44dqsrtY4q3wD89pozcNLUL37cqIkVvQYSW1+ayFm0vb2rgHORhej4X4VU2Ne0kYZQluN0BavfJrrvy77u6JR2SybO8q+GbI4WDGj6aBDShbuhTwbLTM07Cfcjckm34xBpxf0iBV12Y/ZZMmuP/pzZK7HNYcVTGBbX8tVETdKAo6mYpEnAO8IPOIepI748Qhd5SCiDBWhUbu8ggRDgWX7iOhniuk= Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=gabriel.scherer@gmail.com; spf=Pass smtp.mailfrom=gabriel.scherer@gmail.com; spf=None smtp.helo=postmaster@mail-io0-f179.google.com Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of gabriel.scherer@gmail.com) identity=pra; client-ip=209.85.223.179; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="gabriel.scherer@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of gabriel.scherer@gmail.com designates 209.85.223.179 as permitted sender) identity=mailfrom; client-ip=209.85.223.179; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="gabriel.scherer@gmail.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@mail-io0-f179.google.com) identity=helo; client-ip=209.85.223.179; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="postmaster@mail-io0-f179.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0AvAgB9fhJWm7PfVdFeg3tuBqxohSGNayGFeQKBKAc8EAEBAQEBAQEBEAEBAQEBBgsLCSEugh2CBwEBAQMBEhEdARsSCwEDAQsGBQsDCgICCR0CAiIBEQEFAQoSBhMIChCHdgEDCggNmhaBMD4xi0mBbIJ5iTgKGScDClaENgEBAQEBAQQBAQEBARcBBQ6BFIVRhH6FDQeCaYFDBYV+DIZ7iHeFF4gAgh2XehIjgRc4gi8NFgeBVjwziD8BAQE X-IPAS-Result: A0AvAgB9fhJWm7PfVdFeg3tuBqxohSGNayGFeQKBKAc8EAEBAQEBAQEBEAEBAQEBBgsLCSEugh2CBwEBAQMBEhEdARsSCwEDAQsGBQsDCgICCR0CAiIBEQEFAQoSBhMIChCHdgEDCggNmhaBMD4xi0mBbIJ5iTgKGScDClaENgEBAQEBAQQBAQEBARcBBQ6BFIVRhH6FDQeCaYFDBYV+DIZ7iHeFF4gAgh2XehIjgRc4gi8NFgeBVjwziD8BAQE X-IronPort-AV: E=Sophos;i="5.17,638,1437429600"; d="scan'208";a="181148325" Received: from mail-io0-f179.google.com ([209.85.223.179]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 05 Oct 2015 15:49:10 +0200 Received: by ioiz6 with SMTP id z6so185385859ioi.2 for ; Mon, 05 Oct 2015 06:49:09 -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-type; bh=ZoOF+7SKfdrjRWV7HWQuvmYF9sagrxmBXISninLIxf0=; b=TnXyjdMIZHulucnxzncYF6TM5diobl5X8K2TtdhVamPqYF8XrG4e9yg2ubMUcD/u8/ jGxownuZNp3PiciX2IHp8+4dOA4Bh0yE0SQeZHBO2ubMA/cCdaaXqIM91Y7HMJLQe4+K EP6+xzupz4r/PNTLDMY9GCQ7M8GUbNCfc8m0IbxFYYeaaUZ4UGppIEXXsEZK+KpanAX3 iEqkiiH5i+eh89hgSJPJIiGlt+vOLvWawSjhECS+6szouJNzFv2Q6KejmFZ6q8FnH8e5 i62bwvb5L1ZVKajC6e8Y3qlds6GHdGmwQxrftDdzAPtMoRoEK12F1LzDy6vp3FOK0Dda MhQA== X-Received: by 10.107.170.166 with SMTP id g38mr29713620ioj.70.1444052949050; Mon, 05 Oct 2015 06:49:09 -0700 (PDT) MIME-Version: 1.0 Received: by 10.79.19.68 with HTTP; Mon, 5 Oct 2015 06:48:29 -0700 (PDT) In-Reply-To: References: From: Gabriel Scherer Date: Mon, 5 Oct 2015 15:48:29 +0200 Message-ID: To: Jeremie Dimino Cc: "ocaml-core@googlegroups.com" , "caml-list@inria.fr" Content-Type: text/plain; charset=UTF-8 Subject: Re: [Caml-list] [ANN] Jane Street's ppx rewriters Do you plan provide any backward-compatibility guarantees for ppx-core, or do you plan the helpers there to mirror changes to upstream parsetree? (I think there would be a place in the ppx ecosystem for a library that allows users to write rewriters on their current OCaml version, and know that they will still compile and be useable to preprocess OCaml code for future versions. This may require an API with explicit versioning.) On Mon, Oct 5, 2015 at 3:40 PM, Jeremie Dimino wrote: > I am pleased to announce the initial release of the Jane Street's ppx > rewirters. They are now all in opam, and the next release of Core will > be using them. > > They are using a specific framework that we developed to ensure our > rewriters are robust against misuses of new syntaxes. However all > packages export regular ppx executables or ppx_deriving plugins, than > can be used the standard way with ocamlfind. > > This is the list of ppx rewriters that we released so far: > > - ppx_assert (replaces pa_test) > - ppx_bench > - ppx_bin_prot > - ppx_compare > - ppx_csv_conv > - ppx_custom_printf > - ppx_enumerate > - ppx_fail > - ppx_fields_conv > - ppx_here > - ppx_inline_test (replaces pa_ounit) > - ppx_pipebang > - ppx_sexp_conv > - ppx_sexp_value (replaces pa_structural_sexp) > - ppx_typerep_conv > - ppx_variants_conv > - ppx_xml_conv > > In addition we are releasing a few libraries: > > # ppx_core > > This is our PPX standard library. Amongst other things it contains: > > - Various open recursion classes to traverse the OCaml AST: > Ast_traverse.{map,fold,fold_map,...}. This work extends the > Ast_mapper.mapper record of the OCaml compiler libraries. However it > uses names that are closer to the ones in parsetree.mli, so that is > is easier to infer them by just knowing the parsetree. We found that > was helpful when writing ppx related code. > - A framework for attributes and extension points. It deals with > namespacing and make it easier to describe the expected payload. > When used in combination with ppx_driver, it provides helpful error > messages for users. > - Helpers for building and matching the OCaml AST. The building part > is similar to the Ast_helper module of OCaml but with a different > naming convention and no use of a global variable: a functor is provided > to factorize the [~loc] argument. > > # ppx_driver > > This is what we use to handle all of our code rewriting. Instead of > running one process per code transformation, we crunch them all into > one executable. This has several advantages: > > - probably speed, although this hasn't been benchmarked > - a simple way to see the transformed code: no need to build a complex > command line, just run "./ppx file.ml" > - some helpers to debug code transformations > > But more importantly, since the driver has knowledge of all > transformations and all supported attributes and extensions, it can: > > - check that no attribute accidentally ends up being dead code > - give helpful error messages for unused attributes > > For instance: > > # type t = int [@@derivin sexp] > Attribute `derivin' was not used > Hint: Did you mean deriving? > > # type t = int [@deriving sexp] > Attribute `deriving' was not used > Hint: `deriving' is available for type declarations, type extensions > and extension constructors but is used here in the context of a core type. > Did you put it at the wrong level?" > > # type t = { x : int [@default 42] } [@@deriving sexp_of];; > Attribute `default' was not used > > # let%test ("name" [@foo]) = f x = 42;; > Attributes not allowed here > > This is important to us as we don't want people to waste time because > of a misspelled/misplaced attribute. Also when developing rewriters, > we found that it was quite easy to accidentally drop attributes, and > sometimes it is hard to avoid. ppx_driver notifies the user when this > happens. > > # ppx_type_conv > > This is the base library for all our type-driven code generators. It > is similar to ppx_deriving, but with similar requirements as > ppx_driver. Unless used with ppx_driver, ppx_type_conv will just use > ppx_deriving. > > # ppx_optcomp > > This is what we use for when we need conditional compilation. It's has > a cpp-like syntax, which is nice for this kind of things, and works at > the lexer level, which make it possible to use it in pattern matchings > for instance. > > It is used by the lexer fronted of ppx_driver. So if used as a -pp > instead of -ppx, a ppx driver will have optcomp enabled. > > -- > Jeremie Dimino, for the Core team > > -- > 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