Why does the following block of code:
main = do
line <- getLine
if null line
then runTestTT tests
else do
line2 <- getLine
seq::[Int] <- return $ map read $ words line2
print $ process seq
throw an error:
lgis.hs:28:13:
Couldn't match type `()' with `Counts'
Expected type: IO Counts
Actual type: IO ()
In a stmt of a 'do' block: print $ process seq
In the expression:
do { line2 <- getLine;
seq :: [Int] <- return $ map read $ words line2;
print $ process seq }
In a stmt of a 'do' block:
if null line then
runTestTT tests
else
do { line2 <- getLine;
seq :: [Int] <- return $ map read $ words line2;
print $ process seq }
Even though both:
main = do
runTestTT tests
and
main = do
line <- getLine
line2 <- getLine
seq::[Int] <- return $ map read $ words line2
print $ process seq
work fine?