
28 Jan
2011
28 Jan
'11
7:36 p.m.
On Fri, Jan 28, 2011 at 2:20 PM, michael rice
The first and third work, but not the second. Why?
Michael
==============
f :: String -> IO () f s = do putStrLn s
{- g :: [String] -> IO () g l = do s <- l putStrLn s -}
{- h :: [Int] -> [Int] h l = do i <- l return (i+1) -}
Written without the do-notation, your example is
g :: [String] -> IO ()
g l = l >>= \s -> putStrLn s
This won't work because (>>=) has type Monad m => m a -> (a -> m b) ->
m b, and your example requires m to be both [] and IO.
--
Dave Menendez