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 q27GiP98007205 for ; Wed, 7 Mar 2012 17:44:27 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgsQADuPV0/RVdc2imdsb2JhbABDgiAEZYIrrlMCAoEGCCIBAQEKCQ0HEgYjggoBAQEEEgIPHQEbHAEBAwwGBQsNAgIFFgsCAgkDAgECARERAQUBHAYNAQcBAR6HZgSbbQqLKEyCcYVAP4h0AQULgSSJFyqBKYNAgRYElUGFZIE6hxs9hAQ X-IronPort-AV: E=Sophos;i="4.73,545,1325458800"; d="scan'208";a="134880696" Received: from mail-lpp01m010-f54.google.com ([209.85.215.54]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 07 Mar 2012 17:44:23 +0100 Received: by lagv3 with SMTP id v3so14224883lag.27 for ; Wed, 07 Mar 2012 08:44:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=ynvjMXv5DOhlkzMXLL2l0BD9/D3Sl2nLNPXJ/95eKsQ=; b=SzmH1u0iPIUP3eUFC/Ms6GbRNtArefrnUBs+iEE9UJgOOyO5LEhDqltNWI8zkLe/06 4niiutJuyzoSeAGZtdYUMtiVnf2H2WaUv6L0tmE7+se52GSS6O+F8XSoBrmeoFC2l9kC ubBDoKY6WxkEd812fbp30BLn5SZsC1ig9p9ywvR5wmlkUg6KajTPO7gkVBF4Njte5MTF a7bRtbwS8onWwuqWz3Qq3X9Qxxe6MtYwiLov6O1vKuWTrTLRomY3P6f9wZkQOQS6hYiJ B2uhAd/Crv+Bd7i5E68F2Z8OOq7Kh1RXvULwkRA/gpTHLDd9T3VmviCDoo1ZOi6aHB39 pYyA== Received: by 10.152.147.1 with SMTP id tg1mr1902129lab.22.1331138662909; Wed, 07 Mar 2012 08:44:22 -0800 (PST) Received: from [172.27.6.206] ([213.106.240.92]) by mx.google.com with ESMTPS id ox6sm1194128lab.12.2012.03.07.08.44.21 (version=SSLv3 cipher=OTHER); Wed, 07 Mar 2012 08:44:21 -0800 (PST) Message-ID: <4F579064.4020004@gmail.com> Date: Wed, 07 Mar 2012 16:44:20 +0000 From: =?UTF-8?B?TWF0ZWogS2/FocOtaw==?= <5764c029b688c1c0d24a2e97cd764f@gmail.com> User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.1) Gecko/20120216 Thunderbird/10.0.1 MIME-Version: 1.0 To: Gabriel Scherer CC: Caml List References: <4F574B3C.5000207@gmail.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Caml-list] concerning using of `deriving' syntactic plugin On 03/07/2012 12:31 PM, Gabriel Scherer wrote: > 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. I have never used "include" construct myself but I always wanted it. Its cool that we have it :-) The above problem can indeed be solved, i.e. pretty-printer can be generated in this way. The tricky part is to figure out how to define the "Show_t" module definition, which is non-obvious.