[英]Data.Aeson import Key
I have the below code for parsing Int from an object.我有以下代码用于从 object 解析 Int。 But unable to find the correct import for
Key
.但无法找到
Key
的正确导入。
parseInt :: Object -> Key -> Parser Int
parseInt v field =
asum
[ v .: field,
do
s <- v .: field
case readMaybe s :: Maybe Int of
Nothing -> fail "not a number"
Just x -> return x
]
I have tried我努力了
import Data.Aeson
and和
import Data.Aeson.Types
But get the error但是得到错误
Not in scope: type constructor or class ‘Key’
A data constructor of that name is in scope; did you mean DataKinds?
What should be the correct import for Key
in my function?我的 function 中的
Key
的正确导入应该是什么?
It looks like you're writing code targeting aeson
2.x, but that you have aeson
1.x installed.看起来您正在编写针对
aeson
2.x 的代码,但您安装了aeson
Either upgrade (recommended), or use Text
in place of Key
there.要么升级(推荐),要么在此处使用
Text
代替Key
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.