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 D5C07820A1 for ; Mon, 2 Sep 2013 17:59:36 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of edwin+ml-ocaml@etorok.net) identity=pra; client-ip=176.9.138.55; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="edwin+ml-ocaml@etorok.net"; x-sender="edwin+ml-ocaml@etorok.net"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of edwin+ml-ocaml@etorok.net designates 176.9.138.55 as permitted sender) identity=mailfrom; client-ip=176.9.138.55; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="edwin+ml-ocaml@etorok.net"; x-sender="edwin+ml-ocaml@etorok.net"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of postmaster@mail.etorok.net designates 176.9.138.55 as permitted sender) identity=helo; client-ip=176.9.138.55; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="edwin+ml-ocaml@etorok.net"; x-sender="postmaster@mail.etorok.net"; x-conformance=sidf_compatible; x-record-type="v=spf1" X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ag4FAN60JFKwCYo3/2dsb2JhbABagwc1g3i9P4EpFnSCJAEBBSMdAQE4DwsYAgIFIQICDwJGEwgCiAIIpj50g1YBBY4WBoEpjl0WglOBNIkyjkaBL4R9izqDIw X-IPAS-Result: Ag4FAN60JFKwCYo3/2dsb2JhbABagwc1g3i9P4EpFnSCJAEBBSMdAQE4DwsYAgIFIQICDwJGEwgCiAIIpj50g1YBBY4WBoEpjl0WglOBNIkyjkaBL4R9izqDIw X-IronPort-AV: E=Sophos;i="4.89,1007,1367964000"; d="scan'208";a="31207914" Received: from mail.etorok.net ([176.9.138.55]) by mail2-smtp-roc.national.inria.fr with ESMTP; 02 Sep 2013 17:59:35 +0200 Received: from [172.30.42.25] (unknown [79.114.30.210]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.etorok.net (Postfix) with ESMTPSA id DD4C246D8 for ; Mon, 2 Sep 2013 17:59:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=etorok.net; s=mailout; t=1378137575; bh=jbvWmjyhlYUh3cENt2lWzZJER9CNuVCTA9SqlhY2VCU=; l=1678; h=Date:From:To:References:In-Reply-To:From; b=jgMzIFevTBN6nhGI3qVUIWNb0eEGlCCR2/u6erylKnmplUvZ9g3bUytdgJ6Ag7uol vlj3g8S9PQGe1sYDfhq+/cZ+JUgtpjzbcKvpkJjFELQtgq4cvWflPWHYi+HkCJDzbf 9CoBi2MrQt5piEQKuHUL20eDYK6M6Ib73fCjEZck= Message-ID: <5224B5E5.40400@etorok.net> Date: Mon, 02 Sep 2013 18:59:33 +0300 From: =?UTF-8?B?VMO2csO2ayBFZHdpbg==?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130630 Icedove/17.0.7 MIME-Version: 1.0 To: caml-list@inria.fr References: <5224B137.8070706@gmail.com> In-Reply-To: <5224B137.8070706@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Scanned: clamav-milter 0.97.8 at mail X-Virus-Status: Clean Subject: Re: [Caml-list] Literate (sort-of) programming in OCaml On 09/02/2013 06:39 PM, Jonathan Protzenko wrote: > Hi, > > I am currently writing a big, mostly textual document in format blah > (blah being of a course a meta-variable). Are there any tools that > would allow me to interleave OCaml code with the contents of my > document? > > More on my use-case. Creating this document requires me to perform > various subtasks, such as: > - write a code snippet in the document, > - put the code snippet in a file, > - call an external program on the file, > - paste the output into the document. > > Naturally, I wish to automate this. I could roll my own set of > commands, and parse them with OCaml, but I would be re-creating a > scripting language, and it seems to me that interleaving OCaml code > within my document would be better. Here's what I have in mind: > > > blah blah blah blah blah blah blah blah blah blah blah blah blah blah > blah blah > blah blah blah blah blah blah blah blah blah blah blah blah blah blah > blah blah > blah ... we thus write the following code ... : > > {% > let code = "" in > output code > %} > > blah blah blah ... after running the command blah ... the output is as > follows ... blah > > {% > let f = write_into_temp_file code in > let s = run_and_read "myprogram" [f] in > output s > %} > > blah blah blah blah blah blah blah blah blah blah blah blah blah blah > blah blah ... > > > Are you aware of any tool that would allow me to achieve this? http://zoggy.github.io/stog/posts/ocaml-sessions.html https://github.com/realworldocaml/scripts There are probably others. Best regards, --Edwin