module Page ( getPage ) where import Control.Exception (SomeException, try) import Network.HTTP (simpleHTTP, getRequest, getResponseBody) getPage :: String -> IO (Either String String) getPage url = mapLeft show <$> (try (simpleHTTP (getRequest url) >>= getResponseBody) :: IO (Either SomeException String)) mapLeft :: (a -> c) -> Either a b -> Either c b mapLeft f (Left l) = Left (f l) mapLeft _ (Right r) = (Right r)