[Haskell-cafe] Scoping in template haskell
Ryan Ingram
ryani.spam at gmail.com
Wed Mar 19 13:50:34 EDT 2008
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