diff options
Diffstat (limited to 'src/executable/haskell/Utils')
-rw-r--r-- | src/executable/haskell/Utils/HTTP.hs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/executable/haskell/Utils/HTTP.hs b/src/executable/haskell/Utils/HTTP.hs index c901500..919e66d 100644 --- a/src/executable/haskell/Utils/HTTP.hs +++ b/src/executable/haskell/Utils/HTTP.hs @@ -3,18 +3,17 @@ module Utils.HTTP ) where import Control.Exception (SomeException, try) - -import Data.ByteString.Lazy as BS +import Data.ByteString (ByteString) +import qualified Data.ByteString.Lazy as BS import Data.Text (Text) import qualified Data.Text as T -import Data.Text.Encoding as T import Network.HTTP.Conduit import Model.URL import Utils.Either (mapLeft) -get :: URL -> IO (Either Text Text) -get url = mapLeft (T.pack . show) <$> (try (unsafeGetPage url) :: IO (Either SomeException Text)) +get :: (ByteString -> Text) -> URL -> IO (Either Text Text) +get decode url = mapLeft (T.pack . show) <$> (try (unsafeGetPage decode url) :: IO (Either SomeException Text)) -unsafeGetPage :: URL -> IO Text -unsafeGetPage url = (T.decodeLatin1 . BS.toStrict) <$> simpleHttp (T.unpack url) +unsafeGetPage :: (ByteString -> Text) -> URL -> IO Text +unsafeGetPage decode url = (decode . BS.toStrict) <$> simpleHttp (T.unpack url) |