此代码给出以下错误.我该如何解决?
230 let pipeline = [ ["$match" =: matchSelect], 231 ["$group" =: ["_id" =: empty, "sum" =: 232 ["$sum" =: "$score"]]] ] Add.hs:232:40: No instance for (Data.String.IsString v0) arising from the literal `"$score"' The type variable `v0' is ambiguous Possible fix: add a type signature that fixes these type variable(s) Note: there are several potential instances: instance Data.String.IsString Data.Text.Internal.Text -- Defined in `Data.Text' instance Data.String.IsString [Char] -- Defined in `Data.String' In the second argument of `(=:)', namely `"$score"' In the expression: "$sum" =: "$score" In the second argument of `(=:)', namely `["$sum" =: "$score"]' Failed, modules loaded: Utils, Delete, Get, Migrate, Review, Validate.
GS - Apologi.. 8
(=:)
具有多态类型,其中在结果类型中未提及参数中提到的类型变量,因此编译器没有足够的数量来决定表达式中第二个参数的类型"$sum" =: "$score"
.
字符串文字"$score"
给出约束IsString v0
,并(=:)
给出约束Val v0
,但实际上并没有说"它必须是这种类型",并且由于最终结果是Field
没有提及的类型,v
因此最终结果的使用方式无关紧要v
.
最简单的方法是给出"$score"
一个类型签名,例如("$score" :: String)
你真正想要的其他类型.
(=:)
具有多态类型,其中在结果类型中未提及参数中提到的类型变量,因此编译器没有足够的数量来决定表达式中第二个参数的类型"$sum" =: "$score"
.
字符串文字"$score"
给出约束IsString v0
,并(=:)
给出约束Val v0
,但实际上并没有说"它必须是这种类型",并且由于最终结果是Field
没有提及的类型,v
因此最终结果的使用方式无关紧要v
.
最简单的方法是给出"$score"
一个类型签名,例如("$score" :: String)
你真正想要的其他类型.