blob: 8a8ebea1d51ff7811e7b1ebf468388f668100802 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
module Page
( get
) where
import Control.Exception (SomeException, try)
import Data.Text (Text)
import qualified Data.Text as T
import Data.Text.Encoding as T
import Data.ByteString.Lazy as BS
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)
|