blob: b70db7055664834ad16cfa3d5347a32bc9b4223c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
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)
|