merge the haskell implementation to master