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 EEF9E820A1 for ; Mon, 2 Sep 2013 19:26:58 +0200 (CEST) X-IronPort-AV: E=Sophos;i="4.89,1008,1367964000"; d="scan'208";a="31216809" Received: from adijon-153-1-31-185.w83-203.abo.wanadoo.fr (HELO alcazar) ([83.203.202.185]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 02 Sep 2013 19:26:57 +0200 Date: Mon, 2 Sep 2013 19:26:38 +0200 From: Maxence Guesdon To: caml-list@inria.fr Message-ID: <20130902192638.43afc6cd@alcazar> In-Reply-To: <5224B5E5.40400@etorok.net> References: <5224B137.8070706@gmail.com> <5224B5E5.40400@etorok.net> Organization: INRIA X-Mailer: Claws Mail 3.9.2 (GTK+ 2.24.20; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Caml-list] Literate (sort-of) programming in OCaml On Mon, 02 Sep 2013 18:59:33 +0300 T=C3=B6r=C3=B6k Edwin wrote: > On 09/02/2013 06:39 PM, Jonathan Protzenko wrote: > > Hi, > >=20 > > I am currently writing a big, mostly textual document in format blah=20 > > (blah being of a course a meta-variable). Are there any tools that=20 > > would allow me to interleave OCaml code with the contents of my=20 > > document? > >=20 > > More on my use-case. Creating this document requires me to perform=20 > > 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. > >=20 > > Naturally, I wish to automate this. I could roll my own set of=20 > > commands, and parse them with OCaml, but I would be re-creating a=20 > > scripting language, and it seems to me that interleaving OCaml code=20 > > within my document would be better. Here's what I have in mind: > >=20 > >=20 > > blah blah blah blah blah blah blah blah blah blah blah blah blah blah= =20 > > blah blah > > blah blah blah blah blah blah blah blah blah blah blah blah blah blah= =20 > > blah blah > > blah ... we thus write the following code ... : > >=20 > > {% > > let code =3D "" in > > output code > > %} > >=20 > > blah blah blah ... after running the command blah ... the output is as= =20 > > follows ... blah > >=20 > > {% > > let f =3D write_into_temp_file code in > > let s =3D run_and_read "myprogram" [f] in > > output s > > %} > >=20 > > blah blah blah blah blah blah blah blah blah blah blah blah blah blah= =20 > > blah blah ... > >=20 > >=20 > > Are you aware of any tool that would allow me to achieve this? >=20 > http://zoggy.github.io/stog/posts/ocaml-sessions.html You can have a look at a huge usage of this in my ocaml introduction: http://form-ocaml.forge.ocamlcore.org/ The document: http://form-ocaml.forge.ocamlcore.org/intro_ocaml.html The source code: http://forge.ocamlcore.org/scm/?group_id=3D228 You will need stog and stog-writing: http://zoggy.github.io/stog/ http://zoggy.github.io/stog/stog-writing.html Hope this helps, Maxence