IO and syntax

13 Mar 2002 00:10:20 -0800

> readIL' should be defined differently.  Try:
> readIL' ans =
>    do
>       a <- ...
>       b <- ...
>       if a==0 && b==0 then return ans else readIL' ((a,b):ans)
> (note that I added "return".)
> I don't know what the ...s should be, but they definitely should not be
> what they are:  readDec is some kind of number reader, but it doesn't
> deal with actually getting input.  Other people here will know more.
> One way is to use getStr (or is it getStrLn??), split it at
> the space, and then use read to get the numbers.  However, I suspect
> there is a better way.  Good luck.

Ah! You were right - I was confused as to the purpose of readDec and
friends. I changed it to the following, which works:

readIncompatList :: IO [(Player, Player)]
readIncompatList =
    readIL' []
    where readIL' ans =
            do  ln <- getLine
                let [a, b] = map read (words ln)
                if a == 0 && b == 0 then return ans else readIL'



(It occurs to me ... I love Haskell: that "let [a, b] = map read (words
ln)" would be so much longer in C ... :-) )