[Haskell-cafe] some questions about Template Haskell

TP paratribulations at free.fr
Sat Jun 29 22:03:51 CEST 2013


TP wrote:

> 2/ If I define in a module:
> 
> j = 3
> 
> and then define in another module:
> 
> -------------------
> h x = $([|j|])
> main = do
> print $ h undefined
> -------------------
> 
> I obtain "3" as expected.
> 
> However, I do not achieve to make this system work with an infix
> declaration:
> 
> infix $([| j |]) +
> 
> I obtain:
> 
> parse error on input `$('

I don't know what happens exactly, but one way to get out of this problem is 
to write the complete top-level declaration with a splice, instead of only 
the fixity level:

$(return $ [ InfixD (Fixity $([| j |]) InfixN) (mkName "+") ])

Concerning my first question, I have not been able to understand what 
happens at this time. I continue to look at it.

Thanks,

TP




More information about the Haskell-Cafe mailing list