Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Wojciech Meyer <wojciech.meyer@googlemail.com>
To: Mike McClurg <mike.mcclurg@gmail.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Generating a module implementation from a module signature using camlp4
Date: Fri, 12 Oct 2012 18:55:07 +0100	[thread overview]
Message-ID: <wfy5jb1sp0.fsf@gmail.com> (raw)
In-Reply-To: <CALru5wWPvfq9VYyDSHEH=T6bh8FfJyTX9yJrSg-p8fLkAfJO7A@mail.gmail.com> (Mike McClurg's message of "Fri, 12 Oct 2012 18:36:40 +0100")

Hi Mike,

Mike McClurg <mike.mcclurg@gmail.com> writes:

> It seems that I would want to use a camlp4 filter to do this, but as
> far as I can tell it's not possible to create a filter from sig_items
> to str_items. Is a filter the right approach? Am I going to have to
> define my module signatures as module type definitions from within ml
> files? Can anyone give me some some advice on how to do this properly?

You can explicitly pretty print the camlp4 quotations:

open Camlp4
open Camlp4.PreCast
let _loc = Loc.ghost

let foo nm =
  <:str_item<module $uid:nm$ = struct let $lid:String.lowercase nm$ = () end>>


module OCamlPrinter = Camlp4.PreCast.Printers.OCaml;;

OCamlPrinter.print_implem (foo "OK")
==

Then you need some ocamlbuild plugin to create a rule that pipes to a
file.

--
Wojciech Meyer
http://danmey.org

  reply	other threads:[~2012-10-12 17:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-12 17:36 Mike McClurg
2012-10-12 17:55 ` Wojciech Meyer [this message]
2012-10-12 18:03   ` Mike McClurg
     [not found]     ` <507871F9.5040605@gmail.com>
2012-10-12 21:01       ` [Caml-list] " Mike McClurg
2012-10-13 13:06 ` [Caml-list] ocaml 3.12.1 and delimcc Christophe Raffalli
2012-10-13 14:38   ` Anthony Tavener

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=wfy5jb1sp0.fsf@gmail.com \
    --to=wojciech.meyer@googlemail.com \
    --cc=caml-list@inria.fr \
    --cc=mike.mcclurg@gmail.com \
    /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