[Template-haskell] reifyDecl: syntax and semantics

François-Régis Sinot francois-regis.sinot@laposte.net
02 May 2003 16:51:46 +0200


Hi there

"Reification is a language construct, not a function",
as said in the paper. I would like to discuss this choice
a bit, focusing on reifyDecl.

First, I don't really see any justification for this restriction.
As far as I can see, if we say, for instance:
reifyDecl :: String -> Decl
as long as the result is in the quotation monad, it should be okay,
or shoudln't it ? Maybe there are some implementation considerations
that I can't see behind that choice.
I think at least constructs of the form
reifyDecl $(con "Tree")
should be allowed. At present, the parser rejects that.

My second point is that the syntax is inconsistent with the intended 
semantics: for example, the documentation says that it should be
possible to reify a function definition and a prototype.
But if I ask reifyDecl length, what do I expect ? The def or the proto ?
Same thing with reification of instance declarations.
As a matter of fact, the present implementation does not seem to handle
the cases of prototypes and instances, and I don't think it is an urgent
matter. However, I think the syntax should not already forbid that.

My last point, is that it is really impractical. I think it is a pity
that such a powerful construct is in fact almost unusable because of
poor syntactic restrictions. For example, I want to reify a datatype
declaration and then generate a declaration, say for a function,
depending on the structure of the datatype. I can do that, but I can't
abstract from the original datatype, which I am not happy with.

If you're not convinced yet, I can be a bit more specific about what I
want to do. So, what do you think about that ?

-fr-