0
foos <- (return $ map (encode .> cs .> jsonToFoo body) `catch` r400
我有以下類型的錯誤:
/path/to/File.hs:47:78: error:
• Couldn't match type ‘(->) e0’ with ‘IO’
arising from a functional dependency between:
constraint ‘MonadBase IO ((->) e0)’ arising from a use of ‘r400’
instance ‘MonadBase ((->) r) ((->) r)’ at <no location info>
• In the second argument of ‘catch’, namely ‘r400’
In a stmt of a 'do' block:
foos <- (return $ map (encode .> cs .> jsonToFoo) body)
`catch` r400
In the expression:
do { (body :: [Value]) <- requireJsonBody;
foos <- (return $ map (encode .> cs .> jsonToFoo) body)
`catch` r400;
.... }
如果有一種方法,它涉及liftIO
,不是嗎?
嘗試使用[來自提升基礎包的'catch'版本](https://hackage.haskell.org/package/lifted-base-0.2.3.10/docs/Control-Exception-Lifted.html#五:抓)。 –
@AlexisKing謝謝,試試看。 – Wizek
@AlexisKing我得到了完全相同的類型錯誤:'無法匹配類型'( - >)e0'與'IO'' – Wizek