Question

Trying to construct a Request with Network.HTTP.Conduit package. The instructions are:

The constructor for this data type is not exposed. Instead, you should use either the def method to retrieve a default instance, or parseUrl to construct from a URL, and then use the records below to make modifications...

I have no idea what this means. How can I "make modifications" to an immutable Request object; furthermore none of the functions "below" return a Request object!

This is as far as I got:

main = do
    let req = def :: String
    putStrLn "What now? How do I make it a POST?"

Although I am not sure why I used String above either.

Any help appreciated.

Was it helpful?

Solution

It's not at all clear from the documentation, but the "functions below" are actually record labels, so you can use record update syntax to construct the request you want. Of course "modify" here means creating a new request based on the default one, not an actual destructive update.

In other words, something like this:

let req = def { method = methodPost, ... }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top