<div style><div>Hey Haskellers, I had a design question:</div><div><br></div><div>I&#39;m using Haskell for the first time for something other than a simple toy application.  I notice I&#39;m coming up with a lot of IO based APIs that looks something like this:</div>
<div><br></div><div>type UserInfo = (String, String)  -- (name, password)</div><div><br></div><div>getMagicNumberFromHTTPServer :: UserInfo -&gt; IO (Maybe Int)</div><div>getMagicNumberFromHTTPServer user = do</div><div>  let curlHTTPRequest = ... --Setup curl HTTP request</div>
<div>  httpRepsponse &lt;- ... -- Make curl HTTP request</div><div>  return $ tryGetMagicNumberFromResponse httpResponse</div><div><br></div><div>I like this API, because it&#39;s easy to understand.  However, I find it hard to test.  In OO land, I&#39;d create a mock CurlHTTPRequest object and pass that into the magic number logic and test for the correct usage of the curl library.  Is there a FP way of achieving the same goals?</div>
<div><br></div><div>I suppose given the example above I could break down the above into several smaller pure functions and test them.  I don&#39;t know if this strategy will hold-up when dealing with more complex monads.</div>
<div><br></div><div>Thanks for your time,</div><div>Dave</div></div>