<br><br><div class="gmail_quote">2009/10/12 michael rice <span dir="ltr"><<a href="mailto:nowgate@yahoo.com">nowgate@yahoo.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font-family: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-size: inherit; line-height: inherit; font-size-adjust: inherit; font-stretch: inherit;" valign="top">
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.<br><br>Is the second example illegal? If so, is there a different way to change a String to an Int along the >>= chain?<br>
<br>Michael<br><br>===========<br><br>import Data.Char<br><br>{-<br>transform :: IO ()<br>transform = putStrLn "What is your word?"<br> >> getLine<br> >>= \str -> return ('Q':str)<br>
>>= \str -> return ('Z':str)<br> >>= \str -> putStrLn $ "Transformed word is " ++ show str<br>-}<br><br>transform :: IO ()<br>transform = putStrLn "What is your digit
string?"<br> >> getLine<br> >>= \str -> return ('9':str)<br> >>= \str -> return (read str :: Int)<br> >>= \i -> putStrLn $ "The number is " ++ show i<br>
<br></td></tr></tbody></table><br></blockquote><div><br>Both seem good to me and my old ghci (6.6.1)...<br><br>Thu<br></div></div><br>