I hope the spacing is preserved by my email client; here&#39;s a formatting that compiles:<br>
<br>
import System.Environment (getArgs)<br>
<br>
interactWith function inputFile outputFile = do<br>
&nbsp;&nbsp;&nbsp; input &lt;- readFile inputFile<br>
&nbsp;&nbsp;&nbsp; writeFile outputFile (function input)<br>
<br>
main = mainWith myFunction<br>
&nbsp;&nbsp;&nbsp; where mainWith function = do<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; args &lt;- getArgs<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case args of<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [input, output] -&gt; interactWith function input output<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _ -&gt; putStrLn &quot;Usage: Interact inputFile outputFile&quot;<br>
<br>
myFunction = id<br><br><div class="gmail_quote">On Sat, Nov 22, 2008 at 9:53 PM, Robert Kosara <span dir="ltr">&lt;<a href="mailto:rkosara@gmail.com">rkosara@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I&#39;m having some trouble getting the InteractWith example from <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>
<br>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br><br><br><div class="gmail_quote">On Sat, Nov 22, 2008 at 10:41 PM, Ed McCaffrey <span dir="ltr">&lt;<a href="mailto:ed@edmccaffrey.net">ed@edmccaffrey.net</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br><br><div class="gmail_quote"><div><div></div><div class="Wj3C7c">On Sat, Nov 22, 2008 at 9:53 PM, Robert Kosara <span dir="ltr">&lt;<a href="mailto:rkosara@gmail.com" target="_blank">rkosara@gmail.com</a>&gt;</span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="Wj3C7c">
I&#39;m having some trouble getting the InteractWith example from <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>
<br></div></div>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br>
</blockquote></div><br>