Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: "Matej Košík" <5764c029b688c1c0d24a2e97cd764f@gmail.com>
To: Gabriel Scherer <gabriel.scherer@gmail.com>
Cc: Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] concerning using of `deriving' syntactic plugin
Date: Wed, 07 Mar 2012 16:44:20 +0000	[thread overview]
Message-ID: <4F579064.4020004@gmail.com> (raw)
In-Reply-To: <CAPFanBE=DrYN8WZxVs8eB2DK8KhLE-uAzegSM8FVTz7HMydwig@mail.gmail.com>

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.

  reply	other threads:[~2012-03-07 16:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-07 11:49 Matej Košík
2012-03-07 12:31 ` Gabriel Scherer
2012-03-07 16:44   ` Matej Košík [this message]
2012-03-07 17:06     ` Jérémie Dimino
2012-03-07 12:34 ` Yaron Minsky
2012-03-07 16:44   ` Matej Košík
2012-03-07 17:10     ` Markus Mottl
2012-03-07 17:28       ` Matej Košík
2012-03-07 20:47         ` Till Varoquaux
2012-03-08  2:49         ` Markus Mottl

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=4F579064.4020004@gmail.com \
    --to=5764c029b688c1c0d24a2e97cd764f@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=gabriel.scherer@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