Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Mike McClurg <mike.mcclurg@gmail.com>
To: Wojciech Meyer <wojciech.meyer@googlemail.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 19:03:49 +0100	[thread overview]
Message-ID: <CALru5wU3KECQ37g-rsG1t-0V3hgpCybTOEWMwsfX4ABm31Nf+w@mail.gmail.com> (raw)
In-Reply-To: <wfy5jb1sp0.fsf@gmail.com>

On Fri, Oct 12, 2012 at 6:55 PM, Wojciech Meyer
<wojciech.meyer@googlemail.com> wrote:
> 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")

Hi Wojciech,

Thanks for that advice. I attempted something like this earlier, but
even with your printer module I get the following:

Error: This expression has type AstFilters.Ast.str_item
       but an expression was expected of type Camlp4.PreCast.Ast.str_item

Is there any way to unify the modules AstFilters.Ast and
Camlp4.PreCast.Ast? In my earlier attempt I tried some module Foo =
Blah with module ... trickery, but I couldn't seem to unify the types
properly.

Mike

  reply	other threads:[~2012-10-12 18:03 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
2012-10-12 18:03   ` Mike McClurg [this message]
     [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=CALru5wU3KECQ37g-rsG1t-0V3hgpCybTOEWMwsfX4ABm31Nf+w@mail.gmail.com \
    --to=mike.mcclurg@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=wojciech.meyer@googlemail.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