Added Haskell implementation.