Skip to content

Instantly share code, notes, and snippets.

@owainlewis
Last active June 1, 2020 20:30
Show Gist options
  • Save owainlewis/4132852 to your computer and use it in GitHub Desktop.
Save owainlewis/4132852 to your computer and use it in GitHub Desktop.
Haskell HTTP GET request example
module Example () where
import Network.HTTP
-- Non HTTPS
-- 1. Perform a basic HTTP get request and return the body
get :: String -> IO String
get url = simpleHTTP (getRequest url) >>= getResponseBody
-- 2. Get the response code
getCode :: String -> IO ResponseCode
getCode url = simpleHTTP req >>= getResponseCode
where req = getRequest url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment