I'm trying to create a type signature for a function in template haskell. Is there an easy way of doing this?
I've done some workarounds to solve it in the meantime, but it should be easier, right?
-- TH.hs
module Lib.TH (mkFunction) where
import Language.Haskell.TH
mkFunction n = do
let name = mkName n
[d|
$( ... ) :: Integer -> Integer
$(varP name) = \x -> x + 2|]
-- Other.hs
import TH
mkFunction "test"
What should I write in the $( ... )
above? Everything I've tried results in
Invalid type signature: ... :: Integer -> Integer
Should be of form <variable> :: <type>