From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 71DE27EE6A for ; Mon, 3 Jun 2013 22:43:00 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of kosmo.zb@gmail.com) identity=pra; client-ip=209.85.215.42; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="kosmo.zb@gmail.com"; x-sender="kosmo.zb@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of kosmo.zb@gmail.com designates 209.85.215.42 as permitted sender) identity=mailfrom; client-ip=209.85.215.42; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="kosmo.zb@gmail.com"; x-sender="kosmo.zb@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-la0-f42.google.com) identity=helo; client-ip=209.85.215.42; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="kosmo.zb@gmail.com"; x-sender="postmaster@mail-la0-f42.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AmUBAFP/rFHRVdcqjWdsb2JhbABZsCyTFAgWDgEBAQEHCwsJEgYkgiMBAQUnGQE5AwwBBQULDS4iEgEFARwZG4dgAw+eSo9HhSAnDUuIEAEFDI84g0IDlz6PWxYpgV2CWTs X-IPAS-Result: AmUBAFP/rFHRVdcqjWdsb2JhbABZsCyTFAgWDgEBAQEHCwsJEgYkgiMBAQUnGQE5AwwBBQULDS4iEgEFARwZG4dgAw+eSo9HhSAnDUuIEAEFDI84g0IDlz6PWxYpgV2CWTs X-IronPort-AV: E=Sophos;i="4.87,795,1363129200"; d="scan'208";a="16628149" Received: from mail-la0-f42.google.com ([209.85.215.42]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 03 Jun 2013 22:42:59 +0200 Received: by mail-la0-f42.google.com with SMTP id eb20so173597lab.1 for ; Mon, 03 Jun 2013 13:42:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=ooLEnmEQvqzyj2PzgnFsem7dRBLU4DKJ+JYOrnmiGRA=; b=sAAzRrPkMVuLX316a4wjru+C0sbMlgn9JkUn8e7zE2VpRQSSyOmRViyRgGdCizL+2Q bqf4BCPQ56lhfE2zkJ3uc1R9UPzDANxn4910sz1o/PEEYioET0EngJlbb+zdiMwEZQxJ 3SQfG1Wdvsk3slmAoUZwpCVx5adNno0iaMbzQF12jSMqFD82TCoi4WLAWBKxWs3ETXjk LWLCsBq1pzx5nwYlxcnqf+WBoWE6y6o5JtQPclgMWrxbW0ktYF7hkdJfuicaplZjjxcV edKbTCV36wmt9/4F76ilIWqaVeJWnHRX66pxnuRoVETchqnPHEKvsnC4Tlyl4VMQj48H yYOA== MIME-Version: 1.0 X-Received: by 10.112.205.69 with SMTP id le5mr11415184lbc.117.1370292178759; Mon, 03 Jun 2013 13:42:58 -0700 (PDT) Sender: kosmo.zb@gmail.com Received: by 10.112.158.10 with HTTP; Mon, 3 Jun 2013 13:42:58 -0700 (PDT) In-Reply-To: References: Date: Mon, 3 Jun 2013 21:42:58 +0100 X-Google-Sender-Auth: DEu46QiejQp2UJjs_1oNLNJJjUA Message-ID: From: David Sheets To: caml-list@inria.fr Content-Type: text/plain; charset=ISO-8859-1 Subject: [Caml-list] Re: Deepest Lexically Faithful OCaml Syntax Folds I've been told that my attempt at mathematical precision made my original request difficult to understand. Please, permit me to try again and forgive my earlier nonsense: I am looking for a way to annotate OCaml source code while retaining as much original source code layout as possible. Specifically, I would like to have access to as much of the semantic information about the source's components as possible while still retaining token locations suitable for high-quality serialization. Why do I want this? To colorize OCaml source in terminal output. To annotate OCaml source with XML/HTML. To expand and rewrite references in OCaml comments with very clean resulting diffs. Do you know of an OCaml source preprocessor that has properties which would make creation of these tools easy? Do you know of tools that already do some of the above things? Do they do it well? Thanks, David On Sun, Jun 2, 2013 at 6:19 PM, David Sheets wrote: > Hello World, > > I am searching for the "deepest lexically faithful OCaml syntax > catamorphism solution" as the title indicates. What precisely do I > mean by this? > > Deepest => most semantically abstract while retaining a map back to syntax > Lexically faithful => injective, accurate, coordinate-tracked tokens > OCaml syntax => a fine conjuring form > Catamorphism => the source annotations occur as reserialization folds > of some kind > Solution => relatively cheap to integrate > > Specifically, I am looking for a collection of functions like: > > ana ocaml_parse : string -> '_a > cata : '_a -> (('_a -> '_b) * ('_b list -> '_b)) -> '_b > cata' : '_b -> (('_b -> '_c) * ('_c list -> '_c)) -> '_c > . > . > . > serialize : '_c -> ('_c -> string) -> string > > where ana's domain is OCaml source code and cata''s range is (possibly > annotated) OCaml source (which may not be valid for reconsumption > without further processing). The multiplication operator's signature > may vary. > > such that the weakly polymorphic types above can be mapped over by > adding arbitrary annotations. Any number of catamorphic levels is > acceptable. OCaml 3.12 and 4.x syntax support necessary. > > Is the answer some invocation of camlp4, ppx, fan, or compiler > internals? Am I asking for something nonsensical? Have you already > implemented something similar? Do functions equivalent to these exist > in a tool of which you know? > > Thank you, > > David