The first of these works, but not the second. It would seem that the type
cannot change along a >>= chain, but I may be missing something in the code.
Is the second example illegal? If so, is there a different way to change a
String to an Int along the >>= chain?
Michael
===========
import Data.Char
{-
transform :: IO ()
transform = putStrLn "What is your word?"
>> getLine
>>= \str -> return ('Q':str)
>>= \str -> return ('Z':str)
>>= \str -> putStrLn $ "Transformed word is " ++ show str
-}
transform :: IO ()
transform = putStrLn "What is your digit string?"
>> getLine
>>= \str -> return ('9':str)
>>= \str -> return (read str :: Int)
>>= \i -> putStrLn $ "The number is " ++ show i
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe