Leandro Borges Ferreira
11/09/2018, 1:26 AMval updatedState = IO.just(state.copy(guesses = state.guesses.plus(guess))).bind()
//could be just
val updatedState = state.copy(guesses = state.guesses.plus(guess))
Same here:
if (loop) gameLoop(updatedState).bind() else IO.just(updatedState).bind()
//could be just
if (loop) gameLoop(updatedState).bind() else updatedState
And also:
val loop = when {
updatedState.playerWon -> putStrLn("Congratulations ${state.name} you won the game").map { false }
updatedState.playerLost -> putStrLn("Sorry ${state.name} you lost the game. The word was ${state.word}").map { false }
updatedState.word.contains(guess) -> putStrLn("You guessed correctly!").map { true }
else -> putStrLn("That's wrong, but keep trying").map { true }
}.bind()