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

Heinrich Apfelmus apfelmus at quantentunnel.de
Tue Apr 6 09:08:45 EDT 2010

Jacques Carette wrote:
> Jason Dagit wrote:
>> Are you implying that template haskell is not typed?
> Indeed. [...]
> Compare with metaocaml where if you can compile you meta-program (i.e.
> code generator), then you are guaranteed that it can only ever produce
> valid, well-typed code.  Not so with TH, where you can easily generate
> junk -- which GHC will promptly figure out  and give you an error.

I'm curious, can metaocaml create new data type definitions, value
declarations or type class instances? I usually use TH to get rid of
boilerplate that I cannot get rid off in Haskell itself, for instance
for creating functional lenses for record types

    data Foo = Foo { bar_ :: Int, ...}

    $(DeriveLenses Foo)
    -- bar :: Lens Foo Int

It seems to me that metaocaml is more used as "user annotated" partial

Heinrich Apfelmus


More information about the Haskell-Cafe mailing list