-
-
Save deckool/7180441 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- The lack of documentation for these things is crazy | |
module HTTPExamples | |
where | |
import Network.HTTP | |
import Control.Applicative | |
url = "http://www.owainlewis.com" | |
-- Fetch a URL via GET | |
fetch :: String -> IO String | |
fetch url = do | |
response <- simpleHTTP (getRequest url) | |
body <- getResponseBody response | |
return body | |
-- Fetch n chars from a url | |
fetch_chunk :: String -> Int -> IO [Char] | |
fetch_chunk url n = | |
simpleHTTP (getRequest url) >>= | |
fmap (take n) . getResponseBody |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment