How to write a template Haskell function such that:
mkFunc "func"
generates
func = "func"
I've tried this
mkFunc x = ValD (VarP x) (NormalB (LitE (StringL x))) []
But it doesn't typecheck:
Couldn't match type ‘Name’ with ‘[Char]’
Expected type: String
Actual type: Name
In the first argument of ‘StringL’, namely ‘x’
In the first argument of ‘LitE’, namely ‘(StringL x)’
Also, after defining mkFunc
, how can I define mkFuncs
which makes a list of function definitions?