Unfortunately quoted DSLs are limited because any value encoded in one has to be statically known. You can't generate values at runtime. Luckily for the case of SQL generation at least you don't need quotation. Examples from the Haskell world which demonstrate this include Opaleye and HaskellDB. (Disclaimer: I'm the author of Opaleye.)
https://hackage.haskell.org/package/opaleye
https://hackage.haskell.org/package/haskelldb