[Haskell-cafe] Merry monad mixup?

michael rice nowgate at yahoo.com
Fri Jan 28 20:20:32 CET 2011


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)
-} 

==============

serialize2.hs:29:9:
    Couldn't match expected type `[String]'
           against inferred type `IO String'
    In a stmt of a 'do' expression: s <- l
    In the expression:
        do { s <- l;
             putStrLn s }
    In the definition of `g':
        g l = do { s <- l;
                   putStrLn s }




      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110128/64737c57/attachment.htm>


More information about the Haskell-Cafe mailing list