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.

-- 
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

Reply via email to