From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by sympa.inria.fr (Postfix) with ESMTPS id ABFBF7EDE3 for ; Fri, 12 Oct 2012 20:03:52 +0200 (CEST) Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of mike.mcclurg@gmail.com) identity=pra; client-ip=209.85.210.54; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="mike.mcclurg@gmail.com"; x-sender="mike.mcclurg@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail4-smtp-sop.national.inria.fr: domain of mike.mcclurg@gmail.com designates 209.85.210.54 as permitted sender) identity=mailfrom; client-ip=209.85.210.54; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="mike.mcclurg@gmail.com"; x-sender="mike.mcclurg@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-da0-f54.google.com) identity=helo; client-ip=209.85.210.54; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="mike.mcclurg@gmail.com"; x-sender="postmaster@mail-da0-f54.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkUCAMtaeFDRVdI2k2dsb2JhbABFv10IIwEBAQEJCQsJFAQjgiABAQEEEgIsARsdAQMMBgULDS4hAQERAQUBHAYTIodPAQMPnB8JA4wmgnaEfwoZJw1ZiHUBBQyKYGaGPQOUGIFViyODLBYphBA X-IronPort-AV: E=Sophos;i="4.80,577,1344204000"; d="scan'208";a="158874364" Received: from mail-da0-f54.google.com ([209.85.210.54]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 12 Oct 2012 20:03:51 +0200 Received: by mail-da0-f54.google.com with SMTP id z9so1690982dad.27 for ; Fri, 12 Oct 2012 11:03:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=lqKcXhpqcRQ2OptbLIhpt1gVB3GfVYnnjq4acxYgxQ8=; b=qre0ov8x207FMvS5K0Im+r1A9jXil+xuFYDFlBRA/CXSTZk+GFgbo5MostrSv4QOTA r7JDAwEA/Rd+AgQQHDeHnHpk46fdySZhl2T26eh2BMU8/D/rSLnAsel3eUz4ZRWtvOfw tGug/JzlDMcvta0YNk87x6EIxqOzI/9ba+WzTxufKgCshwaUjg7pbz+GPQjH4DGp7XZp Y+v55iRGpyWhmJQNxkbeO9GY4JKf2Rh/5mpnB7XkHlb6zbNrAiac3K/F0wbYpdWbeSHr XseMsk8Oc7MbcblLDtiXeRU+Sdj9nCisGDPxe4+o1cas63srEbuS37R0gtJTgnbhbOUa pmxw== MIME-Version: 1.0 Received: by 10.68.197.194 with SMTP id iw2mr15605024pbc.121.1350065029901; Fri, 12 Oct 2012 11:03:49 -0700 (PDT) Received: by 10.68.124.101 with HTTP; Fri, 12 Oct 2012 11:03:49 -0700 (PDT) In-Reply-To: References: Date: Fri, 12 Oct 2012 19:03:49 +0100 Message-ID: From: Mike McClurg To: Wojciech Meyer Cc: caml-list@inria.fr Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [Caml-list] Generating a module implementation from a module signature using camlp4 On Fri, Oct 12, 2012 at 6:55 PM, Wojciech Meyer wrote: > Hi Mike, > > Mike McClurg 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 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