I'm new to Haskell, so I'm trying to make a simple two player text based game in order to help me learn it.
However, I've come across the problem of performing IO in a "loop". As far as I am aware, variables that are set from user input cannot be used unless they are set inside main. This is a problem because a recursive call to main is useless to me since main does not take any arguments. Ideally, I would have a function called from main that calls itself until one player loses. But, this does not seem to work, since using any variables set in that function by user input results in type errors.
The structure of the program is as follows:
*Prompt player 1 for name and set player1 variable.
*Prompt player 2 for name and set player2 variable.
*The "loop": Alternate between each player, prompting for commands until one player loses.
What would be the best way to go about tackling this problem?