[Haskell-cafe] Re: Metaprogramming in Haskell vs. Ocaml

Heinrich Apfelmus apfelmus at quantentunnel.de
Wed Apr 7 13:30:56 EDT 2010

Nicolas Pouillard wrote:
> Heinrich Apfelmus wrote:
>> I'm curious, can metaocaml create new data type definitions, value
>> declarations or type class instances?
> No metaocaml cannot do this. It is restricted to the expression
> level, and not the declaration level. Moreover you cannot pattern
> match over the generated code.

> Jacques Carette wrote:
>> One thing I should have mentionned - TH and camlp4 are really 
>> equivalents.  And camlp4 is as-typed-as TH (or not, depending on your 
>> point of view).
> This is not exactly the same, TH is a bit more typed than camlp4 here is two
> examples:

Thanks for your clarifications, Jacques and Nicolas. :)

Incidentally, the distinction between camlp4 and metaocaml makes me
wonder whether it might be possible to implement the former *inside* the
latter. In other words, maybe there exists a domain specific language
inside camlp4 / TH that offers all the conveniences of metaocaml.

Of course, this doesn't work right away because camlp4 / TH are
compile-time only, but why not extend them slightly so that they can be
used during run-time, too?

Heinrich Apfelmus


More information about the Haskell-Cafe mailing list