I hope the spacing is preserved by my email client; here's a formatting that compiles:<br>
<br>
import System.Environment (getArgs)<br>
<br>
interactWith function inputFile outputFile = do<br>
input <- readFile inputFile<br>
writeFile outputFile (function input)<br>
<br>
main = mainWith myFunction<br>
where mainWith function = do<br>
args <- getArgs<br>
case args of<br>
[input, output] -> interactWith function input output<br>
_ -> putStrLn "Usage: Interact inputFile outputFile"<br>
<br>
myFunction = id<br><br><div class="gmail_quote">On Sat, Nov 22, 2008 at 9:53 PM, Robert Kosara <span dir="ltr"><<a href="mailto:rkosara@gmail.com">rkosara@gmail.com</a>></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'm having some trouble getting the InteractWith example from <span style="font-style: italic;">Real World Haskell</span>'s
Chapter 4 to compile. When I use spaces (like below), it says
"Interact.hs:10:30: Empty 'do' construct." When I use tabs (4 spaces
per tab), I get "Interact.hs:16:13: parse error on input `='." In
either case, I don't see the problem. Any help would be greatly
appreciated.<div>
<br></div><div>I'm also confused about the formatting of the example in
the book (page 72). The last line ("myFunction = id") 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> input <- readFile inputFile</div><div> writeFile outputFile (function input)</div><div><br></div><div>main = mainWith myFunction</div><div> where mainWith function = do</div><div> args <- getArgs</div>
<div> case args of</div><div> [input, output] -> interactWith function input output</div><div> _ -> putStrLn "Usage: Interact inputFile outputFile"</div><div><br></div><div> 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"><<a href="mailto:ed@edmccaffrey.net">ed@edmccaffrey.net</a>></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"><<a href="mailto:rkosara@gmail.com" target="_blank">rkosara@gmail.com</a>></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'm having some trouble getting the InteractWith example from <span style="font-style: italic;">Real World Haskell</span>'s Chapter 4 to compile. When I use spaces (like below), it says "Interact.hs:10:30: Empty 'do' construct." When I use tabs (4 spaces per tab), I get "Interact.hs:16:13: parse error on input `='." In either case, I don't see the problem. Any help would be greatly appreciated.<div>
<br></div><div>I'm also confused about the formatting of the example in the book (page 72). The last line ("myFunction = id") 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> input <- readFile inputFile</div><div> writeFile outputFile (function input)</div><div><br></div><div>main = mainWith myFunction</div><div> where mainWith function = do</div><div> args <- getArgs</div>
<div> case args of</div><div> [input, output] -> interactWith function input output</div><div> _ -> putStrLn "Usage: Interact inputFile outputFile"</div><div><br></div><div> 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>