[Haskell-cafe] IO () and IO [()]
Jeremy Shaw
jeremy at n-heptane.com
Mon Mar 10 19:02:07 EDT 2008
At Mon, 10 Mar 2008 22:11:33 +0000,
Paulo J. Matos wrote:
> I would like to know if in fact there's any difference in practice
> between (), [()], i.e. if in practice the difference matters.
Well, you could do something like this:
outputLines :: Int -> IO [()]
outputLines i = mapM (putStrLn . show) (take (i*2) $ iterate ((+) 1) 1)
main =
do l <- outputLines 10
putStrLn $ "I putted " ++ show (length l) ++ " lines."
which is not very exciting in this case. But I think I may have done
something similar in real code.
j.
More information about the Haskell-Cafe
mailing list