By the way, you can and probably should define your functions like genQuasiQuote like this:
genQuasiQuote :: Quote m => Name -> Name -> m [Dec]
genQuasiQuote sql dbSql =
[d| $(varP sql)
= QuasiQuoter
{quotePat = error "quasiquoter used in pattern context",
quoteType = error "quasiquoter used in type context",
quoteDec = error "quasiquoter used in declaration context",
quoteExp = $(varE dbSql)} |]
That avoids depending too much on the internal template haskell types.
Edit: You can’t easily splice in a given name into the type signature. You could also consider to let the templates define the names for you automatically, e.g.:
gen :: Quote m => m Exp -> m [Dec]
gen dbExp =
[d| dbSql :: String -> Q Exp
dbSql = unsafeSql $dbExp
sql :: QuasiQuoter
sql
= QuasiQuoter
{quotePat = error "quasiquoter used in pattern context",
quoteType = error "quasiquoter used in type context",
quoteDec = error "quasiquoter used in declaration context",
quoteExp = dbSql} |]