caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jonathan Protzenko <jonathan.protzenko@gmail.com>
To: Ashish Agarwal <agarwal1975@gmail.com>
Cc: Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] Literate (sort-of) programming in OCaml
Date: Mon, 02 Sep 2013 22:16:12 +0200	[thread overview]
Message-ID: <5224F20C.1010905@gmail.com> (raw)
In-Reply-To: <CAMu2m2+T3PVH9nsbW64eiiowfusn9TouW4P6gx0qb1HDF2Y7ng@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 4084 bytes --]

Hi everyone,

Thanks for the numerous replies. There are a lot of good solutions in
there, and the ones that looked closest to what I had in mind seem to be
MPP and the rwo-run-toplevel script. Some questions about these two tools:
- MPP seems to just have the built-in language. I couldn't find any
example in the examples/ directory that used another language, such as
OCaml. I guess that's because it's still in development?
- rwo-run-toplevel seems closer to what I have in mind; if I could send
all the ocaml parts to a top-level session, and put in my document what
gets sent to stdout (not the toplevel reply, that is, not the "val f:
int -> int" parts), that would be pretty much all I need.
rwo-run-toplevel seems to perform a lot of work, though: what are all
these rewrite rules?

Other solutions seemed interesting. The Perl script scared me a little
bit; being no Perl hacker, I would have a hard time using it. The
Markdown library does not seem to be an exact fit (I want the output of
arbitrary OCaml commands to be put in the middle of my markdown.) Stog
seems to be oriented towards reproducing an interactive toploop session,
while I'm more interested in executing arbitrary commands. Alain's sed
trick seems to be exactly what I need, I'm just a bit afraid if I ever
need to change something, it'll be break. But in essence, yes, that's
just all I need. Other proposals seemed a little bit too far away from
what I had in mind.

Thanks again for the replies!

~ jonathan

On 09/02/2013 06:29 PM, Ashish Agarwal wrote:
> OCaml Labs is developing MPP (Meta Preprocessor) [1]. It will be used
> in a new implementation of ocaml.org <http://ocaml.org> [2], which
> includes pages like 99 problems [3] that are generated by running
> ocaml code through the toploop. In case blah = Markdown, please also
> note the new Markdown library [4].
>
> [1] https://github.com/pw374/MPP-language-blender
> [2] http://lists.ocaml.org/pipermail/infrastructure/2013-July/000211.html
> [3] http://ocaml.org/tutorials/99problems.html
> [4] http://lists.ocaml.org/pipermail/infrastructure/2013-July/000223.html
>
>
>
> On Mon, Sep 2, 2013 at 11:39 AM, Jonathan Protzenko
> <jonathan.protzenko@gmail.com <mailto:jonathan.protzenko@gmail.com>>
> 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 = "<sample 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?
>
>     Thanks,
>
>     ~ jonathan
>
>     --
>     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
>
>


[-- Attachment #2: Type: text/html, Size: 7082 bytes --]

  reply	other threads:[~2013-09-02 20:16 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-02 15:39 Jonathan Protzenko
2013-09-02 15:55 ` Alain Frisch
2013-09-02 15:59 ` Török Edwin
2013-09-02 17:26   ` Maxence Guesdon
2013-09-02 16:03 ` Roberto Di Cosmo
2013-09-02 16:29 ` Ashish Agarwal
2013-09-02 20:16   ` Jonathan Protzenko [this message]
2013-09-03  8:34     ` Alain Frisch
2013-09-03 14:34     ` Philippe Wang
2013-09-02 16:39 ` Raphaël Proust
2013-09-02 16:50   ` Simon Cruanes
2013-09-03  0:15 ` oliver
2013-09-03  9:17 ` Alan Schmitt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5224F20C.1010905@gmail.com \
    --to=jonathan.protzenko@gmail.com \
    --cc=agarwal1975@gmail.com \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).