thebook implementation in Haskell