[Haskell-cafe] IO () and IO [()]

Daniel Fischer daniel.is.fischer at web.de
Mon Mar 10 18:48:36 EDT 2008


Am Montag, 10. März 2008 23:34 schrieb Alfonso Acosta:
> 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)

But print is (putStrLn . show), so what may be missing is (putStr . show).


More information about the Haskell-Cafe mailing list