Generating arithmetic expressions in TH

Vitor Rodrigues <[email protected]> Tue, 20 Oct 2009 15:48:28 +0100
Newsgroups gmane.comp.lang.haskell.template
Message-ID <[email protected]>
Hello,

I am starting using TH to generate lambda expressions representing
arithmetic expressions.
My current problem is to generate code where all the lambda
abstractions are in the top level.
For example,

I would like to have

\x -> 1 + x

instead of

1 + (\x -> x)

My problem is that I  don't know in beforehand if the second operand
is a variable or not.
If so, I would like to build a top level abstraction.

It is this possible?

Regards,
Vitor