diff options
author | Joris Guyonvarch | 2015-04-14 00:10:21 +0200 |
---|---|---|
committer | Joris Guyonvarch | 2015-04-14 00:12:04 +0200 |
commit | d3dd0e129658e3617f9e6e4fa0910cb15c42520d (patch) | |
tree | 7eed51e2f4dd9c599daa1d9728a6ca8c86e3897e /src/Page.hs | |
parent | a2c9ca0ee7022981fa563ed867e85cdeae3b1590 (diff) |
Send mail to notify for new ads
Diffstat (limited to 'src/Page.hs')
-rw-r--r-- | src/Page.hs | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/Page.hs b/src/Page.hs index da15ce4..443f768 100644 --- a/src/Page.hs +++ b/src/Page.hs @@ -11,13 +11,11 @@ import Network.HTTP (simpleHTTP, getRequest, getResponseBody) import Model.URL +import Utils.Either (mapLeft) + getPage :: URL -> IO (Either Text Text) getPage url = mapLeft (T.pack . show) <$> (try (unsafeGetPage url) :: IO (Either SomeException Text)) 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) -mapLeft _ (Right r) = (Right r) |