On 22-Nov-1999, c_stanto <[EMAIL PROTECTED]> wrote:
> Sorry I am being a pain, just trying to understand.
> 
> the error is:
> 
> Function main has the type [(Prelude.IO ())] instead of IO ().

Yes, main must return an IO action, not a list of them.

> printTable :: Foo -> [IO ()]
> printTable []     = []
> printTable (x:xs) = putStrLn x : printTable xs
> 
> main :: [IO ()]
> main =  do
>            let tab1 = ...
>            printTable tab1

If you want to convert a list of IO actions into a
single action which executes each of these in turn, then
you can use the `sequence' function:

        main :: IO ()
        main =  do
                   let tab1 = ...
                   sequence (printTable tab1)

However, it may make more sense to do the sequencing in
the `printTable' function itself:

        printTable :: Foo -> IO ()
        printTable []     = return ()
        printTable (x:xs) = do { putStrLn x; printTable xs; }

        main :: IO ()
        main =  do
                   let tab1 = ...
                   printTable tab1

-- 
Fergus Henderson <[EMAIL PROTECTED]>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger [EMAIL PROTECTED]        |     -- the last words of T. S. Garp.

Reply via email to