I&#39;m having some trouble getting the InteractWith example from <span class="Apple-style-span" style="font-style: italic;">Real World Haskell</span>&#39;s Chapter 4 to compile. When I use spaces (like below), it says &quot;Interact.hs:10:30: Empty &#39;do&#39; construct.&quot; When I use tabs (4 spaces per tab), I get &quot;Interact.hs:16:13: parse error on input `=&#39;.&quot; In either case, I don&#39;t see the problem. Any help would be greatly appreciated.<div>
<br></div><div>I&#39;m also confused about the formatting of the example in the book (page 72). The last line (&quot;myFunction = id&quot;) seems to be indented between the where and the next line, why is that? Is that simply a layout problem? To me, it seems it should be on the same level as the where.</div>
<div><br></div><div>Below is my program:</div><div><br></div><div><div>-- Interact.hs, simple filter in Haskell</div><div><br></div><div>import System.Environment (getArgs)</div><div><br></div><div>interactWith function inputFile outputFile = do</div>
<div>&nbsp;&nbsp; &nbsp;input &lt;- readFile inputFile</div><div>&nbsp;&nbsp; &nbsp;writeFile outputFile (function input)</div><div><br></div><div>main = mainWith myFunction</div><div>&nbsp;&nbsp; &nbsp;where mainWith function = do</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;args &lt;- getArgs</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;case args of</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[input, output] -&gt; interactWith function input output</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_ -&gt; putStrLn &quot;Usage: Interact inputFile outputFile&quot;</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;myFunction = id</div>
<div><br></div><div><br></div><div>Regards,</div><div><br></div><div>Robert</div><div><br></div></div>