I cannot figure out to call something from an expression generated with TemplateHaskell. Let's say I want to use ":" operator to cons list.
I saw syntax '(:)
but it is not working for me.
Also I tried to lookupNameValue and wrap mkName ":"
into (AppE (VarE (mkName ":"))
, but none of above is working...
{-# LANGAUGE TemplateHaskell #-}
{-# LANGAUGE TemplateHaskellQuotes #-}
{-# LANGUAGE QuasiQuotes #-}
import Language.Haskell.TH
import Language.Haskell.TH.Syntax as S
import Language.Haskell.TH.Quote
useColon :: Q [Dec]
useColon = do
let fName = mkName "f"
pure [ FunD fName
[Clause []
(NormalB (InfixE (Just (LitE (IntegerL 1)))
'(:)
(Just (ListE [])))) []]
]
• Syntax error on '(:) Perhaps you intended to use TemplateHaskell or TemplateHaskellQuotes • In the Template Haskell quotation '(:) | 36 | '(:) | ^^^^