.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
import Control.Exception (try)

eitherToMaybe :: Either a b -> Maybe b
eitherToMaybe (Left _) = Nothing
eitherToMaybe (Right a) = Just a
--eitherToMaybe = either (const Nothing) Just                                   

getTitle :: Url -> IO (Maybe String)
getTitle u = do
    e <- try $ getTitleExn u
    return $ eitherToMaybe e

getTitleExn :: Url -> IO String
getTitleExn url = ... list !! index ... head ...