Hi all,<br>I am trying to Network.HTTP to connect to a website and catch the error if the network is down. Here's what I have so far:<br><br>data Errors = DocumentParseError<br> | WebsiteUnreachableError<br>
| ISBNNotFoundError<br><br>respHTML' :: ISBN -> IO (Either Errors (IO String))<br>respHTML' isbn =<br> do<br> rsp <- simpleHTTP (getRequest $ "<a href="http://isbndb.com/api/books.xml?results=details&access_key=">http://isbndb.com/api/books.xml?results=details&access_key=</a>"<br>
++ key<br> ++ "&index1=isbn&value1="<br> ++ isbn :: Request_String)<br> return $ Right $ getResponseBody rsp<br>
`E.catch` (\(e :: E.SomeException ) -><br> return $ Left $ WebsiteUnreachableError)<br><br>I get the following error when I load it into GHCI:<br> Couldn't match expected type `[Char]'<br>
against inferred type `Either Errors b'<br> Expected type: IO String<br> Inferred type: IO (Either Errors b)<br> In the expression: return $ Left $ WebsiteUnreachableError<br> In the second argument of `E.catch', namely<br>
`(\ (e :: E.SomeException)<br> -> return $ Left $ WebsiteUnreachableError)'<br>Failed, modules loaded: none.<br><br>Control.Exception.catch has the following signature : <br>catch :: forall a. IO a -> (IOError -> IO a) -> IO a<br>
<br>I would expect that the handler function needs to return an IO (Either Errors (IO String)). Why is it trying to return an IO String?<br>