On Fri, Jan 28, 2011 at 2:20 PM, michael rice <[email protected]> wrote: > > 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 <[email protected]> <http://www.eyrie.org/~zednenem/> _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
