[Haskell-cafe] Can type be changed along a >>= chain?

michael rice nowgate at yahoo.com
Mon Oct 12 12:53:51 EDT 2009


Dumb! I just figured out I was entering the input string in quotes.

So, I suppose the answer to my question is yes, type CAN be changed along a >>= chain. I was having trouble doing it in a different problem, created this small example to illustrate the problem, and then screwed it up putting quotes around my input string.

Thanks!

Michael

--- On Mon, 10/12/09, Niklas Broberg <niklas.broberg at gmail.com> wrote:

From: Niklas Broberg <niklas.broberg at gmail.com>
Subject: Re: [Haskell-cafe] Can type be changed along a >>= chain?
To: "michael rice" <nowgate at yahoo.com>
Cc: haskell-cafe at haskell.org
Date: Monday, October 12, 2009, 12:43 PM

On Mon, Oct 12, 2009 at 6:37 PM, michael rice <nowgate at yahoo.com> wrote:

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

This code works perfectly for me. What problem are you seeing specifically?
Cheers,/Niklas



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091012/cf9d0b07/attachment.html


More information about the Haskell-Cafe mailing list