I'm using mysql-simple
and when I build the program, I get the following error:
我正在使用mysql-simple,当我构建程序时,我收到以下错误:
No instance for (Database.MySQL.Simple.Param.Param (IO String))
arising from a use of ‘execute’
In a stmt of a 'do' block: num <- execute c q v
I guess it's the IO String
which mysql-simple
doesn't want in its parameters.
我想这是mysql-simple在其参数中不需要的IO String。
What is the ideomatic way to handle this?
处理这个问题的理想方法是什么?
Edit: I tested it with ""
and it worked fine.
编辑:我用“”测试它,它工作正常。
1 个解决方案
#1
If v
is an IO String
, i.e. an IO action producing a String
, and execute
expects something of type String
, you first have to ”run” v
. So instead of
如果v是IO字符串,即产生字符串的IO操作,并且execute需要String类型的东西,则首先必须“运行”v。所以而不是
num <- execute c q v
you have to write
你必须写
str <- v
num <- execute c q str
#1
If v
is an IO String
, i.e. an IO action producing a String
, and execute
expects something of type String
, you first have to ”run” v
. So instead of
如果v是IO字符串,即产生字符串的IO操作,并且execute需要String类型的东西,则首先必须“运行”v。所以而不是
num <- execute c q v
you have to write
你必须写
str <- v
num <- execute c q str