Added haskell implementation