In my program I need to make a decision based on user input. Let's say the valid inputs are one
, two
, three
. I first need to convert such an input to an Int because I need to compare it to other data in my program. Which is why I have a function toInt :: String -> Int
which turns a String into an Int (one = 1, two = 2, three = 3). As of now I try to use getLine
to retrieve the user input however this is of type IO String
so I can't use my function with this input.
Thus my questions are: should I use getLine in this case? And if so how can I modify the user input or toInt
so that it will work? And if not what else can I do so that I can get toInt
to work with the user input?