Even more succinctly:

sequence_ . map is mapM_, and putStrLn . show is print, so you get:

mapM_ print films

Dan

On Sun, May 10, 2009 at 9:59 PM, Alex MDC <[email protected]> wrote:
> 2009/5/11 applebiz89 <[email protected]>
>>
>> I know to use show and putStrLn but I just don't know how to put them into
>> the function correctly
>
> Well I hope we're not doing your homework for you but...
>
> As putStrLn is in the IO monad, listFilms should at least have a signature
> like this:
>
> listFilms :: [Film] -> IO ()
>
> Now you know you want to call putStrLn on each item in the list. That means
> you want to join a bunch of functions return IO (). That sounds like a job
> for sequence_:
>
> listFilms films = sequence_ $ map (putStrLn.show) films
>
> Or the same thing more verbosely:
>
> listFilms [] = return ()
> listFilms (film:films)
>  = do putStrLn (show film)
>       listFilms films
>
> Hope that helps,
> Alex
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to