Added Haskell implementation