我正在尝试处理来自我的请求解析器的异常:
go bs =
case try $ parseRequest reader bs secure of
Left ex -> exceptionHandler writer ex
Right (request, bs') -> do
sendResponse writer =<< app request
go bs'
但是我在使用时遇到了一个问题try
:
Couldn't match expected type `IO (Either e0 (Request, ByteString))'
with actual type `Either t0 t1'
In the pattern: Left ex
In a case alternative: Left ex -> exceptionHandler writer ex
In the expression:
case try $ parseRequest reader bs secure of {
Left ex -> exceptionHandler writer ex
Right (request, bs')
-> do { sendResponse writer =<< app request;
go bs' } }
IO (Either e0 (Request, ByteString))
正是我得到的,try
因为它的类型是try :: Exception e => IO a -> IO (Either e a)
,但我得到了Either e a
。
我错过了什么?