0
这里是我的尝试:如何将FromJSON实现为参数的类型传递给anoter函数?
decode :: String -> FromJSON a => BS.ByteString -> a
decode fnm iFromJSONable = do
ymlData <- BS.readFile fnm
let ymlDecode :: Maybe iFromJSONable
ymlDecode = Data.Yaml.decode ymlData
return fromJust ymlDecode
错误:
Couldn't match type `a' with `IO b0'
`a' is a rigid type variable bound by
the type signature for
Yaml.decode :: String -> FromJSON a => BS.ByteString -> a
at src\Yaml.hs:46:11
Expected type: IO BS.ByteString -> (BS.ByteString -> IO b0) -> a
Actual type: IO BS.ByteString
-> (BS.ByteString -> IO b0) -> IO b0
In a stmt of a 'do' block: ymlData <- BS.readFile fnm