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