diff options
Diffstat (limited to 'src/Page.hs')
-rw-r--r-- | src/Page.hs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/Page.hs b/src/Page.hs new file mode 100644 index 0000000..b70db70 --- /dev/null +++ b/src/Page.hs @@ -0,0 +1,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) |