From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id q27CWJGr028253 for ; Wed, 7 Mar 2012 13:32:19 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AuYBAGVUV09KfVK2kGdsb2JhbABDhTSeBZFVCCIBAQEBCQkNBxQEI4IKAQEBBBICDx0BGxILAQMMBgMCCw0CAgkdAgIhAQERAQUBChIGExIQh2YLnBMKiyhMgnGFRD+IdAEFC4EkiAqGIIEWBJVBiyGDGD2EBQ X-IronPort-AV: E=Sophos;i="4.73,545,1325458800"; d="scan'208";a="134829573" Received: from mail-we0-f182.google.com ([74.125.82.182]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 07 Mar 2012 13:32:13 +0100 Received: by werl4 with SMTP id l4so6660454wer.27 for ; Wed, 07 Mar 2012 04:32:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=M7RBT2ateYiXIWXnE+4g8YYalvz1sNwkjJU+sYc8grk=; b=vIpaSdJ6ybWTcTaFj9shWQ96eTgbuUKINIRvxpNz8BThlSCrZFSBBRB6GIbRoS1iB8 J0Cv4qjKR/v7gknb9NczaBJXifoyB7H/lgdK+9NHFV0DRKIQvEyk8yQFE62LA6bAKAY7 xp23sOCqrZeLQ3QkmAOoJ+pqM2SDOfAPKI4HH701tCcG7PB0JLfvLlqal4LayHi9nLnC XPMek6yzGbJHEWOe2phNRGvBKkJkPYfwhgWazazKPTHIsd2qx2z94a2wq5BdWhaNdF93 mNV9I6G87rt4XcL9M7IJZnZW020B8j1hSuAeft+3xVnCbAYKQLJh8kVjq0TWaVmOLJ0j uGbA== Received: by 10.180.88.199 with SMTP id bi7mr3533039wib.12.1331123533224; Wed, 07 Mar 2012 04:32:13 -0800 (PST) MIME-Version: 1.0 Received: by 10.227.200.85 with HTTP; Wed, 7 Mar 2012 04:31:32 -0800 (PST) In-Reply-To: <4F574B3C.5000207@gmail.com> References: <4F574B3C.5000207@gmail.com> From: Gabriel Scherer Date: Wed, 7 Mar 2012 13:31:32 +0100 Message-ID: To: =?UTF-8?B?TWF0ZWogS2/FocOtaw==?= <5764c029b688c1c0d24a2e97cd764f@gmail.com> Cc: Caml List Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id q27CWJGr028253 Subject: Re: [Caml-list] concerning using of `deriving' syntactic plugin You can inject the definition you want in the following way: module Meths = struct include Meths module Show_t = ... end type value_kind = ... deriving (Show) This works because deriving, being a Camlp4 extension, does not refer to "the" module Meths, but any module Meths that is in scope at the place of expansion. This could be seen as a defect of hygiene (indeed that makes camlp4 macro non-hygienic according to the Scheme notion of hygiene) but is also a feature, rather than a bug, of the syntactic macro system; because as a macro-writer you can give flexibility to the user by specifying the free variables you rely on. On Wed, Mar 7, 2012 at 12:49 PM, Matej Košík <5764c029b688c1c0d24a2e97cd764f@gmail.com> wrote: > Hi, > > I would like to print out the response of a modified Ocaml's typechecker > to various inputs. > > One way to do it would be to write a pretty-printer by hand. > > Before I do that, I would like to apply "deriving" machinery: > http://code.google.com/p/deriving/wiki/Introduction > to this (chore) job. > > In some cases I do not know what to do. > > E.g., file "types/types.mli" contains the following definition: > >  and value_kind = >      Val_reg >    | Val_prim of Primitive.description >    | Val_ivar of mutable_flag * string >    | Val_self of >        (Ident.t * type_expr) Meths.t ref * >        (Ident.t * mutable_flag * virtual_flag * type_expr) Vars.t ref * >      string * type_expr >    | Val_anc of (string * Ident.t) list * string >    | Val_unbound > > If I add > >  deriving (Show) > > at the end of the above definition, I get an error: > >  Error: Unbound module Meths.Show_t > > That is expected but I am not sure what to do. That is, I am not sure > what is the official way to "deriving"-sify the "Meth" module which > defined in the following way: > >  module Meths = Map.Make(OrderedString) > > without the need to modify files "map.ml{i,}". > > Is something like that possible? > > Thank you very much in advance for any help. > > -- > Caml-list mailing list.  Subscription management and archives: > https://sympa-roc.inria.fr/wws/info/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs >