Reputation: 4993
When I tried:
foos <- (return $ map (encode .> cs .> jsonToFoo body) `catch` r400
I got the following type error:
/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;
.... }
If there is a way, it involves liftIO
, doesn't it?
Upvotes: 1
Views: 255
Reputation: 4993
I was just missing the argument for catch
:
foos <- (return $ map (encode .> cs .> jsonToFoo body)
`catch` (\(e :: SomeException) -> r400)
Too bad it wasn't more apparent for me from the type error.
Upvotes: 2