A game for two in which one player tries to guess the letters of a word, and failed attempts are recorded by drawing a gallows and someone hanging on it, line by line. Ps.: The gallows was not implemented.
This is an IO Monad exercise used by Erik Meijer - DelftX: FP101x Introduction to Functional Programming
You will need to install a Haskell compiler. I have used Glasgow Haskell Compiler - ghc
$ ghc hangman.hs
$ ./hangman
Enter a secret word: *******
Try to guess: h
h______
Try to guess: ha
ha___a_
Try to guess: hang
hang_an
Try to guess: hangman
You win!!!
Or
$ ghci
GHCi, version 7.10.2: http://www.haskell.org/ghc/ :? for help
Prelude> :load hangman.hs
[1 of 1] Compiling Main ( hangman/hangman.hs, interpreted )
Ok, modules loaded: Main.
*Main> main
Enter a secret word: *******
Try to guess: h
h______
Try to guess: ha
ha___a_
Try to guess: hang
hang_an
Try to guess: hangman
You win!!!
- Draw gallows and someone hanging on it.