[Haskell-beginners] Trouble with formatting,
Real World Haskell example
Ed McCaffrey
ed at edmccaffrey.net
Sat Nov 22 22:41:29 EST 2008
On Sat, Nov 22, 2008 at 9:53 PM, Robert Kosara <rkosara at gmail.com> wrote:
> I'm having some trouble getting the InteractWith example from Real World
> Haskell'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.
> 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.
>
> Below is my program:
>
> -- Interact.hs, simple filter in Haskell
>
> import System.Environment (getArgs)
>
> interactWith function inputFile outputFile = do
> input <- readFile inputFile
> writeFile outputFile (function input)
>
> main = mainWith myFunction
> where mainWith function = do
> args <- getArgs
> case args of
> [input, output] -> interactWith function input output
> _ -> putStrLn "Usage: Interact inputFile outputFile"
>
> myFunction = id
>
>
> Regards,
>
> Robert
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20081122/e37ea330/attachment.htm
More information about the Beginners
mailing list