[Haskell-cafe] IO () and IO [()]
Alfonso Acosta
alfonso.acosta at gmail.com
Mon Mar 10 18:34:51 EDT 2008
On Mon, Mar 10, 2008 at 11:11 PM, Paulo J. Matos <pocm at soton.ac.uk> wrote:
> outputLines i = mapM (putStrLn . show) (take i $ iterate ((+) 1) 1)
>
> However, this is in fact
> outputLines :: Int -> IO [()]
As others suggested you can use mapM_
Furthermore, you can simplify it a bit with some syntactic sugar
outputLines i = mapM_ (putStrLn . show) [1..i]
BTW, considering how often is (putStrLn.show) used, it is surprising
that there is no Ln variant for print (just like it happens with
putStr and putStrLn)
More information about the Haskell-Cafe
mailing list