[Haskell-cafe] tried to use the example given in the source of network.browser

Michael Litchard michael at schmong.org
Fri Oct 22 09:58:01 EDT 2010


This is what is in HTTPbis/Network/Browser.hs

>    do
>      rsp <- Network.Browser.browse $ do
>               setAllowRedirects True -- handle HTTP redirects
>               request $ getRequest "http://google.com/"
>      fmap (take 100) (getResponseBody rsp)


And how I changed it slightly to test it out


> import Network.HTTP
> import Network.Browser


> main =
>     do
>     rsp <- Network.Browser.browse $ do
>              setAllowRedirects True -- handle HTTP redirects
>              request $ getRequest "http://google.com/"
>     fmap (take 100) (getResponseBody rsp)

but I got this errortest.lhs:10:39:
    Couldn't match expected type `Network.Stream.Result (Response [a])'
           against inferred type `(Network.URI.URI, Response String)'
    In the first argument of `getResponseBody', namely `rsp'
    In the second argument of `fmap', namely `(getResponseBody rsp)'
    In the expression: fmap (take 100) (getResponseBody rsp)


how did I get this error? I'm perplexed as this came right from the source.


More information about the Haskell-Cafe mailing list