Fetching a URI

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Fetching a URI

Adam Keys
I'm trying to write a wrapper for a REST service. However, I find  
myself stumped by the simplest part: merely performing a GET on a URI.

I'm using the HTTP Cabal package. It specifies an example like so:

> simpleHTTP (getRequest "http://www.haskell.org/") >>= fmap (take  
> 100) . getResponseBody


However, it seems I'm either importing the library incorrectly or  
there is a discrepancy between the documentation and the library. I  
can't seem to call getRequest.

> :) ghc-pkg list
> ...
> /Users/adamkeys/.ghc/i386-darwin-6.8.2/package.conf:
>     Cabal-1.6.0.1, HTTP-3001.1.3, HTTP-4000.0.4, Shellac-0.9.5,
> ...
>
> GHCi, version 6.8.2: http://www.haskell.org/ghc/  :? for help
> Loading package base ... linking ... done.
> Prelude> import Network.HTTP
> Prelude Network.HTTP> :type getRequest
>
> <interactive>:1:0: Not in scope: `getRequest'

Am I missing something obvious here?

--
~akk

Reply | Threaded
Open this post in threaded view
|

Fetching a URI

aditya siram-2
At first I got the same error but when I installed HTTP-4000.0.5 using Cabal
your code worked.

hth,
deech

On Sun, Apr 5, 2009 at 10:07 PM, Adam Keys <[hidden email]> wrote:

> I'm trying to write a wrapper for a REST service. However, I find myself
> stumped by the simplest part: merely performing a GET on a URI.
>
> I'm using the HTTP Cabal package. It specifies an example like so:
>
>  simpleHTTP (getRequest "http://www.haskell.org/") >>= fmap (take 100) .
>> getResponseBody
>>
>
>
> However, it seems I'm either importing the library incorrectly or there is
> a discrepancy between the documentation and the library. I can't seem to
> call getRequest.
>
>  :) ghc-pkg list
>> ...
>> /Users/adamkeys/.ghc/i386-darwin-6.8.2/package.conf:
>>    Cabal-1.6.0.1, HTTP-3001.1.3, HTTP-4000.0.4, Shellac-0.9.5,
>> ...
>>
>> GHCi, version 6.8.2: http://www.haskell.org/ghc/  :? for help
>> Loading package base ... linking ... done.
>> Prelude> import Network.HTTP
>> Prelude Network.HTTP> :type getRequest
>>
>> <interactive>:1:0: Not in scope: `getRequest'
>>
>
> Am I missing something obvious here?
>
> --
> ~akk
>
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20090405/be4f76a1/attachment.htm
Reply | Threaded
Open this post in threaded view
|

Fetching a URI

Aleksandar Dimitrov
In reply to this post by Adam Keys
Hi Adam,

>> ghc-pkg list
>> ...
>> /Users/adamkeys/.ghc/i386-darwin-6.8.2/package.conf:
>>    Cabal-1.6.0.1, HTTP-3001.1.3, HTTP-4000.0.4, Shellac-0.9.5,
>> ...

It seems you have two versions of HTTP installed. I'm not really sure
about HTTP-3.x.x.x's API, but I'd wage a guess that it doesn't define
`getRequest`. When importing in ghci, your installation probably picks
the older one instead of the new version.

Try hiding the old package and see if it fixes your problem:

> ghc-pkg hide HTTP-3001.1.13

You can unhide it using `ghc-pkg unhide HTTP-3001.1.13`.

HTH,
Aleks