module Utils.HTTP ( get ) where import Control.Exception (SomeException, try) import 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)) unsafeGetPage :: URL -> IO Text unsafeGetPage url = (T.decodeLatin1 . BS.toStrict) <$> simpleHttp (T.unpack url)