Taking a second look, I can see some improvements:...
# arrow
l
Taking a second look, I can see some improvements:
Copy code
val 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:
Copy code
if (loop) gameLoop(updatedState).bind() else IO.just(updatedState).bind()
//could be just
if (loop) gameLoop(updatedState).bind() else updatedState
And also:
Copy code
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()