Converting IO Int --> Int

Can anyone tell me how to convert a value of type IO Int to a value of type Int. I wrote a simple script to read an integer from the user using IO and then the value is returned from the IO function using return value with a return type of IO Int. In the calling function I wish to do a comparison with the user value and a hard-coded integer. Unfortunately I keep getting type errors between the Int and the IO Int. I would be grateful for any assistance in this. Thanks in advance, Tim Stitt

Tim Stitt writes: | Can anyone tell me how to convert a value of type IO Int to a value of type | Int. | | I wrote a simple script to read an integer from the user using IO and then | the value is returned from the IO function using | | return value | | with a return type of IO Int. | | In the calling function I wish to do a comparison with the user value and a | hard-coded integer. Unfortunately I keep getting type errors between the Int | and the IO Int. | | I would be grateful for any assistance in this. Here's a link to an explanation of what's going on there. http://haskell.org/hawiki/ThatAnnoyingIoType

Am new to haskell, however is this what you mean : num <- getLine let x = read num :: Int -- ?? Greets, Jad Saklawi Tim Stitt wrote:
Can anyone tell me how to convert a value of type IO Int to a value of type Int.
I wrote a simple script to read an integer from the user using IO and then the value is returned from the IO function using
return value
with a return type of IO Int.
In the calling function I wish to do a comparison with the user value and a hard-coded integer. Unfortunately I keep getting type errors between the Int and the IO Int.
I would be grateful for any assistance in this.
Thanks in advance,
Tim Stitt _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (3)
-
Jad Saklawi
-
Tim Stitt
-
Tom Pledger