我有以下用于從物件決議 Int 的代碼。但無法找到正確的匯入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
]
我努力了
import Data.Aeson
和
import Data.Aeson.Types
但是得到錯誤
Not in scope: type constructor or class ‘Key’
A data constructor of that name is in scope; did you mean DataKinds?
Key在我的函式中正確的匯入應該是什么?
uj5u.com熱心網友回復:
看起來您正在撰寫針對aeson2.x 的代碼,但您aeson安裝了 1.x。升級(推薦),或Text代替Key那里使用。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/416352.html
標籤:
