google hosed my indentation<br><br>> obtainCookies :: IO Curl -> String -> IO ()<br>> obtainCookies curl responseBody = do<br>> curl' <- curl<br>> mapM_ (flip (curlResp curl') resourceOpts) $<br>
> screenScraping responseBody<br><br><br><br><div class="gmail_quote">On Wed, Jan 26, 2011 at 3:32 PM, Michael Litchard <span dir="ltr"><<a href="mailto:michael@schmong.org">michael@schmong.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Thank you.<br><br><pre>Here is where things stand now<div class="im"><br><br>> obtainCookies :: IO Curl -> String -> IO ()<br>
> obtainCookies curl responseBody = do<br>> curl' <- curl<br></div><div class="im">> mapM_ (flip (curlResp curl') resourceOpts) $<br>
> screenScraping responseBody<br><br><br></div>and the error<br><br>htmlParsing.lhs:78:2:<div class="im"><br>Couldn't match expected type `[Char]'<br></div>against inferred type `GHC.IO.Exception.IOException'<br>
Expected type: String<br>
Inferred type: IOError<br>When using functional dependencies to combine<br>MonadError IOError IO,<br>arising from the dependency `m -> e'<br>in the instance declaration at <no location info><br>MonadError String IO,<br>
arising from a use of `curlResp' at HtmlParsing.lhs:80:29-42<br>When generalising the type(s) for `obtainCookies'<br><br>I'm way beyond my ken here, trying to grow. I have to do error handling (this will be production code when it grows up), got some suggestions on how to do so, but am flying blind in new territory.<br>
<br>Any suggestions on how to proceed would be much appreciate<code><span>d.</span></code></pre><div><div></div><div class="h5"><br><div class="gmail_quote">On Wed, Jan 26, 2011 at 3:13 PM, Daniel Fischer <span dir="ltr"><<a href="mailto:daniel.is.fischer@googlemail.com" target="_blank">daniel.is.fischer@googlemail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div>On Wednesday 26 January 2011 23:51:18, Michael Litchard wrote:<br>
> Here's what I'm working with, followed by what I am trying to do, and<br>
> the type error I get. I'm leaving things out that I do not think are<br>
> important. Let me know if I'm missing nessecary info.<br>
> ><br>
> ><br>
</div><div>> > obtainCookies :: IO Curl -> String -> IO ()<br>
> > obtainCookies curl responseBody = do<br>
> > curl' <- curl<br>
> > let collectedResources = screenScraping responseBody<br>
> > in mapM ( curlResp curl' resourceOpts)<br>
><br>
> collectedResources<br>
><br>
<br>
</div>Looks like you need a flip here:<br>
<br>
in mapM (flip (curlResp curl') resourceOpts) collectedResources<br>
<br>
> > return ()<br>
<br>
If you're throwing away the results of the MapM'ed actions, use mapM_<br>
<div><br>
obtainCookies curl responseBody = do<br>
curl' <- curl<br>
</div> mapM_ (flip (curlResp curl') resourceOpts) $<br>
screenScraping responseBody<br>
<div><br>
><br>
> this function does a monadic action (all I want is the cookies) and I<br>
> don't need the return value. I am not sure that the final line return<br>
> (), is what I want.<br>
><br>
><br>
> My primary question is this. how do I map over collectedResources<br>
> correctly? Secondary question, is the return correct?<br>
<br>
</div>Use mapM_<br>
<br>
</blockquote></div><br>
</div></div></blockquote></div><br>