importSystem.IOimportData.ListimportData.Chardisplay::String->Stringdisplayword=intersperse' '[ifc`elem`['a'..'z']then'_'elsec|c<-word]makeGuess::String->Char->Int->IO()makeGuesswordletterguesses|letter`elem`word=play[ifletter==cthentoUpperletterelsec|c<-word]guesses|otherwise=playword(guesses-1)play::String->Int->IO()playwordguesses|word==maptoUpperword=doputStrLn$displaywordputStrLn"You Win!"|guesses==0=doputStrLn$displaywordputStrLn"You Lose..."|otherwise=doputStrLn$"You have "++showguesses++" guesses left."putStrLn$displaywordputStr"Guess a letter: "hFlushstdoutuserGuess<-getLinecaseuserGuessofc:_->makeGuessword(toLower$headuserGuess)guesses_->putStrLn"Please enter a letter a-z">>playwordguessesmain::IO()main=doputStrLn"Welcome to Haskell Hangman!"putStr"Enter a word (or sentence) to guess: "hFlushstdoutuserInput<-getLine-- Get a string from user and store it in userInputcaseuserInputofc:_->play(maptoLoweruserInput)6-- This last int is the amount of wrong guesses the player will have_->putStrLn"Please input at least one character!">>mainputStrLn"Thanks for playing!"