I'm writing a simple program in Haskell that lets user input exponent of the power of 2
power a = 2^a
main = do
number <- readLn
let x = (read number :: Int)
power x
I figured out that I need to convert String to Int but i still get following error: No instance for (Num (IO t0)) arising from a use of 'power'
How do I make it work?
reading afterreadLnis a bad idea.readLn = readIO =<< getLineso you'll read a line, parse that into aString(requiring proper quoting and escaping), and then parse that again into a number. Just usereadLn