0
我通過阿爾喬姆的埃宋教程工作,並已編碼自己這個片斷:這段代碼如何推斷類型?
parseFoo (Object obj) = do
a <- case HM.lookup "a" obj of
Just x -> parseJSON x
Nothing -> fail "no field 'a'"
return a
我發現,如果我return True
,我得到一個「不明確的引用」錯誤:
No instance for (FromJSON t0) arising from a use of ‘parseJSON’
The type variable ‘t0’ is ambiguous
Note: there are several potential instances:
...
該類型的非模糊情況是
parseFoo :: FromJSON b => Value -> Parser b
我的問題是,爲什麼(如何)不a
需要return
語句來推斷它的類型?