[Haskell-cafe] Scoping in template haskell

Lars Oppermann loppermann at acm.org
Thu Mar 20 05:23:46 EDT 2008


Thanks for pointing me in the right direction... especially the
mentioning of lowercase constructors helped a lot. I'll clean up my
actual code (creating XML representation of record-style datatypes) a
bit and post it. Maybe you or someone else has some comments.

Bests,
Lars

On Wed, Mar 19, 2008 at 6:50 PM, Ryan Ingram <ryani.spam at gmail.com> wrote:
> On Wed, Mar 19, 2008 at 10:46 AM, Ryan Ingram <ryani.spam at gmail.com> wrote:
>  >   gen1 i = LitE $ StringE $ "<<" ++ show i ++ ">>"
>
>  Oops, two mistakes here:
>  1) StringE should be StringL
>  2) splices need to be in the Q monad.
>
>  To fix (2), you can either add a "return" here, or, there are
>  conveniently lowercase constructors for much of TH that return results
>  in the Q monad:
>  > gen1 i = return $ LitE $ StringL $ "<<" ++ show i ++ ">>"
>  or
>  > gen1 i = litE $ StringL $ "<<" ++ show i ++ ">>"
>


More information about the Haskell-Cafe mailing list