Haskell implementation of Hisashi Hayashi's Trains