In this case, the problem is that the State constructor has been removed in the latest version of the Monad Transformer Library. If you replace the use of State in the definition of getNext with State , then the program works fine. (This is due to the fact that State was redefined as StateT Identity , i.e., a state transformer on a monodate monad, and therefore a separate data type was deleted. If you do not know what this means, do not worry about it just means that you should replace State with State whenever you see it.)
Most problems with existing examples on the Internet or in RWH are simply due to newer versions of the libraries. (I think the main problem with RWH examples is that Parsec examples are written for Parsec 2, Parsec 3 has been changed quite a bit, so at least you probably have to add some imports.)
All in all, Haskell really suffers from a lack of modern useful resources; that the HaskellWiki page is simply not supported. (Although HaskellWiki is indeed an official site of haskell.org, the pages are written and maintained by users, therefore simply because something on the wiki does not necessarily mean its relevance or high quality.)
The release of the Monad Transformer library, which State removed, was released in October 2010, so itβs a shame that there is still a lot of code that does not work with the new version because of this. Fortunately, the fix is ββsimple.
source share