Magicloud Magiclouds | 3 Jul 08:25 2013
Picon

How to use Template Haskell based on code that generated by another Template?

I have a yesod project, which generated, say, UserPassword in module Model.
Then I wrote my template code which generate a piece of code to use UserPassword. I imported Model in my code.

Then I got
Illegal variable name: `UserPassword'
    When splicing a TH declaration:
--
竹密岂妨流水过
山高哪阻野云飞

And for G+, please use magiclouds#gmail.com.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
adam vogt | 3 Jul 17:04 2013
Picon

Re: How to use Template Haskell based on code that generated by another Template?

On Wed, Jul 3, 2013 at 2:25 AM, Magicloud Magiclouds
<magicloud.magiclouds <at> gmail.com> wrote:
> Then I got
> Illegal variable name: `UserPassword'
>     When splicing a TH declaration:

Hi Magicloud,

GHC seems to be trying to tell you that variables are lowercase in
haskell. Since you don't have code, I'm guessing your error is from
doing something like:

> wrong1 = print ($(dyn "Just") 5)
> wrong2 = print ($(varE 'Just) 5)

Which is a compile time error since you apparently can't pass a Name
which is capitalized to `VarE :: Name -> Exp'

Any of these options work. They use the  `ConE :: Name -> Exp'
constructor instead:

> opt1 = print ($(conE (mkName "Just")) 5)
> opt2 = print ($(conE 'Just) 5)
> opt3 = print ($( [| Just |]) 5 )

--
Adam
Magicloud Magiclouds | 4 Jul 03:45 2013
Picon

Re: How to use Template Haskell based on code that generated by another Template?

Yes, I misunderstood the generated code and splice shown in error message. Thanks.


On Wed, Jul 3, 2013 at 11:04 PM, adam vogt <vogt.adam <at> gmail.com> wrote:
On Wed, Jul 3, 2013 at 2:25 AM, Magicloud Magiclouds
<magicloud.magiclouds <at> gmail.com> wrote:
> Then I got
> Illegal variable name: `UserPassword'
>     When splicing a TH declaration:

Hi Magicloud,

GHC seems to be trying to tell you that variables are lowercase in
haskell. Since you don't have code, I'm guessing your error is from
doing something like:

> wrong1 = print ($(dyn "Just") 5)
> wrong2 = print ($(varE 'Just) 5)

Which is a compile time error since you apparently can't pass a Name
which is capitalized to `VarE :: Name -> Exp'

Any of these options work. They use the  `ConE :: Name -> Exp'
constructor instead:

> opt1 = print ($(conE (mkName "Just")) 5)
> opt2 = print ($(conE 'Just) 5)
> opt3 = print ($( [| Just |]) 5 )

--
Adam



--
竹密岂妨流水过
山高哪阻野云飞

And for G+, please use magiclouds#gmail.com.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Gmane