On Sat, Dec 15, 2012 at 1:30 PM, Michael Sloan <mgsl...@gmail.com> wrote:
> I don't think that there is a particular reason for not supporting > quasi-quotes in where clauses.. It should be added! > > The reason for /splices/ to not be supported in here statements is that > they are run during type checking. That way calls to "reify" can access > type information for things before your splice. It also allows checking > any AST quotes used inside your splice. Since type-checking comes after > renaming, splices can't be used in patterns (because it would affect the > lexical scope). > > Quasi-quotes, on the other hand, are run in the renamer, and ought to be > able to be used in where clauses. Yet for some reason they can't - I get > "parse error (possibly incorrect indentation or mismatched brackets)" when > I try to put one under a where. > > Good catch! > -Michael > Yeah, that is the problem. I have a function inside which I need to generate some declarations using TH. I can not generate these at the top level as these generations depend on the function's parameters which are local to the function. Something like f p1 p2= ... where -- this has to be generated by TH g_1 = p1 g_2 = p2 g_3 = p1 `xor` p2 something like the above. In the above I have shown only 2 parameters but in my case it is much more. I am able to get the above splice as toplevel declaration but I am still unsuccessful in getting it inside the where. I can always make `g` a function and take parameters of `f` as arguments in the top level splice but that will defeat the purpose of optimization here(which I am trying to do), as that would result in a function call every time I use `g` instead of above variables.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe