diff options
author | Joris Guyonvarch | 2015-04-11 20:38:08 +0200 |
---|---|---|
committer | Joris Guyonvarch | 2015-04-11 20:38:08 +0200 |
commit | aafc45eb5eed3839a5210a7d48928d975df6a296 (patch) | |
tree | 8574205bdf967b7338e63bc77c2f1374e0843e67 /src/Page.hs | |
parent | 4ddd6d1f6df2bab75d42b6d45b816e92e7173529 (diff) |
Handle a configuration file to save the url
Diffstat (limited to 'src/Page.hs')
-rw-r--r-- | src/Page.hs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/Page.hs b/src/Page.hs index b048410..da15ce4 100644 --- a/src/Page.hs +++ b/src/Page.hs @@ -4,18 +4,19 @@ module Page import Control.Exception (SomeException, try) +import Data.Text (Text) import qualified Data.Text as T import Network.HTTP (simpleHTTP, getRequest, getResponseBody) import Model.URL -getPage :: URL -> IO (Either T.Text T.Text) +getPage :: URL -> IO (Either Text Text) getPage url = - mapLeft (T.pack . show) <$> (try (unsafeGetPage url) :: IO (Either SomeException T.Text)) + mapLeft (T.pack . show) <$> (try (unsafeGetPage url) :: IO (Either SomeException Text)) -unsafeGetPage :: URL -> IO T.Text -unsafeGetPage url = simpleHTTP (getRequest url) >>= (\x -> T.pack <$> getResponseBody x) +unsafeGetPage :: URL -> IO Text +unsafeGetPage url = simpleHTTP (getRequest (T.unpack url)) >>= (\x -> T.pack <$> getResponseBody x) mapLeft :: (a -> c) -> Either a b -> Either c b mapLeft f (Left l) = Left (f l) |