Dear Alejandro,
I'd also be interested in this.
I haven't had the chance to use `{-# LINE ... #-}` pragmas before, but I do have some experience with TH.
It might help us to get closer to a solution if you described what the transformation is actually doing, and/or include some examples of before and after transformation. It could at the very least help me understand more of the context.
Thinking further about the question, it seems to me that as soon as our expression has already been transformed to `Exp` (or `Q Exp`) all positional and formatting information is lost.
But maybe there is still hope.
Have you considered using the 'haskell-src-meta' package? And/or using QuasiQuotes to transform "String -> Q Exp"? I have a vague memory that there is a haskell-parsing package or project out there (even if it is not specifically 'haskell-src-meta') that does retain the positional information that you are looking for when parsing from String (or `IsString a`).
Once we do have line numbers, including them as pragmas seems fairly straightforward as `PragmaD (LineP Int String) :: Dec`
Best Regards,
Milán